Page 1 of 2

7-zip32.dll wrapper

Posted: Wed Mar 28, 2007 2:20 am
by ts-soft
This is a IncludeFile for 7-zip32.dll using static lib.

Unfortunately, I haven't found documentation (except in Japanese), but I
hope so, it's also useful

The folder-structure corresponds in the IncludePack used, 7-zip32.dll is in the
compilers subdirectory.
http://www.purebasic.fr/english/viewtop ... ncludepack

Example:

Code: Select all

XIncludeFile #PB_Compiler_Home + "Includes\7-zip32_Include.pbi"

Define.l HARC = SevenZipOpenArchive(0, #PB_Compiler_Home + "Includes\Libraries\sourcen\7-zip32.7z", #ARCEXTRACT_OPEN)
Define.INDIVIDUALINFO INFO

If HARC

  If Not SevenZipFindFirst.l(HARC, "*.*", @INFO)
    Debug INFO\szFileName

    While Not SevenZipFindNext(HARC, @INFO)
    
      Debug INFO\szFileName
      
    Wend
  EndIf
  SevenZipCloseArchive.l(HARC)
EndIf
The Not is the same as = 0 :wink:

Download 336kb

Feedback and Bug-Reports welcome

Greetings
Thomas

Posted: Wed Mar 28, 2007 5:11 am
by JCV
Thanks. I might need this. :D

Posted: Wed Mar 28, 2007 5:56 am
by ts-soft
@JCV
You are welcome :D

Another small example to pack as 7z

Code: Select all

XIncludeFile #PB_Compiler_Home + "Includes\7-zip32_Include.pbi"

; this small programm makes a backup of purebasic with all subdirectories and files
; in the tempdir as 7z

Procedure BackUpPB()
  Protected Output.s = Space(255)
  Protected Destination.s = #DQUOTE$ + GetTemporaryDirectory() + "purebasic_bak" + #DQUOTE$
  Protected CmdLine$ =  "a -t7z -mx7 -ir!*.* " + Destination + " " + #DQUOTE$ + "*.*" + #DQUOTE$
  SetCurrentDirectory(#PB_Compiler_Home)
  If SevenZip(WindowID(0), CmdLine$, Output, 255) = 0
    ProcedureReturn #True
  EndIf
  Debug Output
  ProcedureReturn #False
EndProcedure

If OpenWindow(0, 0, 0, 140, 60, "PureBasic Backup", #PB_Window_ScreenCentered | #PB_Window_SystemMenu)
  If CreateGadgetList(WindowID(0))
    ButtonGadget(0, 30, 20, 80, 30, "Make Backup")
    Repeat
      Select WaitWindowEvent()
        Case #PB_Event_CloseWindow
          Break
        Case #PB_Event_Gadget
          If EventGadget() = 0
            If BackUpPB()
              RunProgram("explorer.exe", "/e," + GetTemporaryDirectory(), ""); show the result
            EndIf
            Break
          EndIf
      EndSelect
    ForEver
  EndIf
EndIf
The Syntax is nearly the same as for the commandline-version of 7-Zip

Posted: Wed Mar 28, 2007 7:33 am
by Psychophanta
Thanks, i was waiting for 7z to be available for management with PB :)

Posted: Wed Mar 28, 2007 12:11 pm
by Inf0Byt3
OMG! :shock: . ts-soft, I love you man! Thanks!

[Edit]
Can this be used in a commercial project? :?

Posted: Wed Mar 28, 2007 2:44 pm
by ts-soft
Inf0Byt3 wrote:Can this be used in a commercial project? :?
Is the same license as 7zip, LGPL, see copying.txt!
You can use in commercial projects!

Posted: Wed Mar 28, 2007 3:12 pm
by ts-soft
Only one line changed to create a sfx-installer with passwort :wink:

Code: Select all

XIncludeFile #PB_Compiler_Home + "Includes\7-zip32_Include.pbi"

Procedure CreatePBSetup()
  Protected Output.s = Space(255)
  Protected Destination.s = #DQUOTE$ + GetTemporaryDirectory() + "purebasic_setup" + #DQUOTE$
  Protected CmdLine$ =  "a -sfx -mx7 -p -ir!*.* " + Destination + " " + #DQUOTE$ + "*.*" + #DQUOTE$
  SetCurrentDirectory(#PB_Compiler_Home)
  If SevenZip(WindowID(0), CmdLine$, Output, 255) = 0
    ProcedureReturn #True
  EndIf
  Debug Output
  ProcedureReturn #False
EndProcedure

If OpenWindow(0, 0, 0, 140, 60, "PureBasic Setup", #PB_Window_ScreenCentered | #PB_Window_SystemMenu)
  If CreateGadgetList(WindowID(0))
    ButtonGadget(0, 30, 20, 80, 30, "Make Setup")
    Repeat
      Select WaitWindowEvent()
        Case #PB_Event_CloseWindow
          Break
        Case #PB_Event_Gadget
          If EventGadget() = 0
            If CreatePBSetup()
              RunProgram("explorer.exe", "/e," + GetTemporaryDirectory(), ""); show the result
            EndIf
            Break
          EndIf
      EndSelect
    ForEver
  EndIf
EndIf

Posted: Wed Mar 28, 2007 7:40 pm
by Inf0Byt3
This is awesome! Been waiting for a very long time for this. Thank you for your efforts!

Posted: Wed Mar 28, 2007 8:08 pm
by ts-soft
I have found an english API-Description:
http://www.csdinc.co.jp/archiver/lib/7-zip32api-en.txt

Posted: Thu Mar 29, 2007 6:16 pm
by ts-soft
Small Update for unicode compatible

Changed some stringparameter to pseudotype ASCII
Some parameter as optional declared
In structures all strings as character defined! Read it with peeks!

Posted: Mon Apr 16, 2007 12:47 pm
by nrasool
nice on Ts-Soft. Have you thought about putting this code and examples in your excellent PBOSL library?

Posted: Mon Apr 16, 2007 3:25 pm
by Dare
ts-soft wrote:Unix is user friendly... it's just selective about who its friends are!
lol. :D

Thanks for the 7-zip!

Re: 7-zip32.dll wrapper

Posted: Tue Jun 01, 2010 2:39 pm
by dige
is this project sill activ? the dl link is broken...

Re: 7-zip32.dll wrapper

Posted: Tue Jun 01, 2010 3:55 pm
by ts-soft
dige wrote:is this project sill activ?
No
dige wrote: the dl link is broken...
I think the DLL comes with PureFileMaster by Al90, or use the commandline-interface from 7zG.exe,
is easy to use.

Re: 7-zip32.dll wrapper

Posted: Wed Jun 02, 2010 7:31 am
by dige
Could you pls put the old sources available again?