Click here to Skip to main content
12,300,245 members (56,247 online)
Click here to Skip to main content
Add your own
alternative version

Stats

56.8K views
1.9K downloads
10 bookmarked
Posted

Iterate and Extract Cabinet File

, 24 May 2004 CPOL
Rate this:
Please Sign up or sign in to vote.
Iterate and extract Cabinet File

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

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

aplaxas
France France
No Biography provided

You may also be interested in...

Comments and Discussions

 
GeneralThanks so much its working fine for me. Pin
shahshi24-Aug-10 21:22
membershahshi24-Aug-10 21:22 
GeneralThe system cannot find the file specified Pin
mikey22217-Oct-09 13:07
membermikey22217-Oct-09 13:07 
GeneralEssential!!! Pin
Rakshun29-Aug-09 8:04
memberRakshun29-Aug-09 8:04 
GeneralSomething is wrong!It cannot open the 2nd cab file. Pin
winxp8455-Jan-09 10:12
memberwinxp8455-Jan-09 10:12 
GeneralError opening second cab Pin
Xtravar24-Oct-08 7:53
memberXtravar24-Oct-08 7:53 
QuestionSome Questions! Pin
lilish18-Dec-06 9:07
memberlilish18-Dec-06 9:07 
GeneralA little more work required Pin
Colin Angus Mackay25-May-04 9:55
memberColin Angus Mackay25-May-04 9:55 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.160525.2 | Last Updated 25 May 2004
Article Copyright 2004 by aplaxas
Everything else Copyright © CodeProject, 1999-2016
Layout: fixed | fluid