Introduction
The .NET Framework doesn't provide us with Cabinet File functionality through the programming interface. However, the Setupapi.dll enables us to handle cabinet files except for compressing. This TCabinet
class encapsulates some functions of the Setupapi.dll in order to iterate and extract a cabinet file.
Background
TCabinet
class encapsulates the following functions in setupapi.dll:
[DllImport("SetupApi.dll", CharSet=CharSet.Auto)]
public static extern bool SetupIterateCabinet(string cabinetFile,
uint reserved, PSP_FILE_CALLBACK callBack, uint context);
public delegate uint PSP_FILE_CALLBACK(uint context, uint notification,
IntPtr param1, IntPtr param2);
private uint CallBack(uint context, uint notification, IntPtr param1,
IntPtr param2)
{
uint rtnValue = SetupApiWrapper.NO_ERROR;
switch (notification)
{
case SetupApiWrapper.SPFILENOTIFY_FILEINCABINET:
rtnValue = OnFileFound(context, notification, param1, param2);
break;
case SetupApiWrapper.SPFILENOTIFY_FILEEXTRACTED:
rtnValue = OnFileExtractComplete(param1);
break;
case SetupApiWrapper.SPFILENOTIFY_NEEDNEWCABINET:
rtnValue = SetupApiWrapper.NO_ERROR;
break;
}
return rtnValue;
}
History
- 25th May, 2004: Initial post