Cab file extracting utility

Just starting out? Need help? Post your questions and find answers here.
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by El_Choni.

Hi. I'm coding this cab file extracting utility which doesn't work. You'll see a strange function, CabExtract(), which calls a library I've coded for this little app. The program is supposed to list the files in the cab, but it doesn't. Can anybody tell me if something is wrong with the PB code? Otherwise, the library is to blame (if someone wishes to take a look at the asm source of the library, I'll send it). Thanks.

Code: Select all

InitGadget(3)

If CreateMenu(0)
  MenuTitle("&File")
    MenuItem(0, "&Open")
    MenuItem(1, "&Extract")
    MenuBar()
    MenuItem(2, "&Quit")
EndIf

MenuHeight = 56

If OpenWindow(1,#CW_USEDEFAULT,#CW_USEDEFAULT,#CW_USEDEFAULT,#CW_USEDEFAULT,#PB_Window_SystemMenu|#PB_Window_MinimizeGadget,"CAB Extract")

  AttachMenu(0, WindowID())

  If CreateGadgetList(WindowID())
    ListIconGadget(0, 0, 0, WindowWidth(), WindowHeight(), "File", WindowWidth()/4)
    AddGadgetColumn(0, 1, "Size", WindowWidth()/4)
    AddGadgetColumn(0, 2, "Modified", WindowWidth()/4)
    AddGadgetColumn(0, 2, "Path", WindowWidth()/4)
  EndIf

  Repeat

    EventID.l = WaitWindowEvent()

    Select EventID
      Case #PB_EventMenu
        Select EventMenuID()
          Case 0 ; Open
            file.s = OpenFileRequester("Open cabinet file","","Cabinet files (*.cab)|*.cab", 0)
            If file""
              ClearGadgetItemList(0)
              bufferpointer = AllocateMemory(0, 16384, 0)
              CabExtract(file, 1, bufferpointer)
              While bufferpointer ""
              CabExtract(file, 0, 0)
            EndIf
          Case 2 ; Close
            Quit = 1
        EndSelect
      Case #PB_EventCloseWindow
        Quit = 1
    EndSelect
  Until Quit = 1
EndIf

End
Bye,

El_Choni
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by fred.

Your code looks correct. BTW, why after a PeekS() you add '2' to your buffer ? Any special requests ? Len() return the real length (starting to 1) so if you want to skip the ending '0' byte (PeekS() ends only on a 0 byte) just add 1.



Fred - AlphaSND
Post Reply