Microsoft requires drivers developers to pack the drivers files into a single cab and code sign it. I was looking for a way to do so programmatically. I found the MakeCab tool but from first look it allows passing one parameter for the file, so I was looking for the right way to pack several files.
The .Cab format seems to be a bit outdated. It was created by Microsoft when files which were part of a Setup application needed to be packed into disks. Even today, when a .cab file is created it will be created in folders named "Disk1", "Disk2", etc. My code also simplifies that by allowing a simple function call:
Another interesting fact related to MakeCab is that the only way to add several files into a new .cab would be creating a file containing a list of all files to be added. My function does that for you. It then cleans up and you will only find the .cab created.
The Building Blocks
I will start by showing you a few building blocks we use in Secured Globe, Inc. First, a function that is used to execute a command, as if it has been typed and executed via CMD, collecting the result and displaying it back to you. In case of an error, composing a friendly error description.
bool DoRun(WCHAR *command)
LPTSTR pTemp = NULL;
TCHAR Command[BUFSIZE] = L"";
_tcscpy_s(Command, L"/C ");
_tcscat_s(Command, L" >");
bool result = ShellExecute(GetActiveWindow(), L"OPEN", L"cmd", Command, NULL, 0L);