Using 7Zip.dll in UNICODE [Resolved]

Just starting out? Need help? Post your questions and find answers here.
tester
User
User
Posts: 34
Joined: Sun Dec 28, 2014 1:12 pm

Re: Using 7Zip.dll in UNICODE [Resolved]

Post by tester »

Code: Select all

;
; PB 5.71 LTS (x86)
; 7Zip.dll IN UNICODE [Resolved]
; https://www.purebasic.fr/english/viewtopic.php?f=13&t=68262
; Latest 7-zip32.dll: http://www.csdinc.co.jp/archiver/lib/7-zip32.html#download
; 7-zip32 api doc: http://www.csdinc.co.jp/archiver/lib/7-zip32api-en.zip
;
EnableExplicit

Prototype.i SevenZip(Window.i, *CmdLine, *OutputAnsi, OutputSize.i)
Prototype.i SevenZipSetUnicodeMode(setUnicode.i)

Procedure$ SevenZipCmdLine(CmdLine$)
  Protected Id7Zip.i, wn, *CmdLine, Output$, OutputUTF8$
  Protected SevenZipSetUnicodeMode.SevenZipSetUnicodeMode
  Protected SevenZip.SevenZip
  Id7Zip=OpenLibrary(#PB_Any,"7-zip32.dll")
  If Id7Zip
    ;Debug "Library 7-zip32.dll opened"
    ;If ExamineLibraryFunctions(Id7Zip)
    ;  While NextLibraryFunction()
    ;    Debug LibraryFunctionName()
    ;  Wend
    ;EndIf
    
    SevenZipSetUnicodeMode=GetFunction(Id7Zip, "SevenZipSetUnicodeMode")
    If Not SevenZipSetUnicodeMode : Output$="SevenZipSetUnicodeMode procedure not present in 7-zip32.dll" : Goto SevenZipCmdLineOut : EndIf
    SevenZip=GetFunction(Id7Zip, "SevenZip")
    If Not SevenZip : Output$="SevenZip procedure not present in 7-zip32.dll" : Goto SevenZipCmdLineOut : EndIf
    wn=OpenWindow(#PB_Any, 300, 200, 320, 200, "7zip",#PB_Window_ScreenCentered|#PB_Window_Invisible)
    If wn
      OutputUTF8$ = Space(32767)
      *CmdLine = UTF8(CmdLine$)
      SevenZipSetUnicodeMode(#True) ; Return value always TRUE.
      If Not SevenZip(WindowID(wn), *CmdLine, @ OutputUTF8$, 32767)
        Output$=PeekS(@ OutputUTF8$, -1, #PB_UTF8)
      Else
        Output$="An error occurred."
      EndIf
      
    EndIf
  Else
    Output$="7-zip32.dll not present"
  EndIf
  
  SevenZipCmdLineOut:
  If Id7Zip : CloseLibrary(Id7Zip) : EndIf
  If *CmdLine : FreeMemory(*CmdLine) : EndIf
  
  ProcedureReturn Output$
EndProcedure

;Add to archive all files in the current directory
MessageRequester("", SevenZipCmdLine("a Test.zip *.*"))
;Test lists contents of the zip file
;Debug SevenZipCmdLine("l Test.zip")
MessageRequester("", SevenZipCmdLine("l TEST.zip"))
hoangdiemtinh
User
User
Posts: 97
Joined: Wed Nov 16, 2022 1:51 pm

Re: Using 7Zip.dll in UNICODE [Resolved]

Post by hoangdiemtinh »

DLL files
---------

7za.dll and 7zxa.dll are reduced versions of 7z.dll from 7-Zip.
7za.dll and 7zxa.dll support only 7z format.
Note: 7z.dll is main DLL file that works with all archive types in 7-Zip.

7za.dll and 7zxa.dll support the following decoding methods:
- LZMA, LZMA2, PPMD, BCJ, BCJ2, COPY, 7zAES, BZip2, Deflate.

7za.dll also supports 7z encoding with the following encoding methods:
- LZMA, LZMA2, PPMD, BCJ, BCJ2, COPY, 7zAES.

7za.dll and 7zxa.dll work via COM interfaces.
But these DLLs don't use standard COM interfaces for objects creating.
PC: Windows 10 x64, 8GB RAM. PB ver: 6.x
--
I love PB5 vs PB6 :)
User avatar
mk-soft
Always Here
Always Here
Posts: 6244
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: Using 7Zip.dll in UNICODE [Resolved]

Post by mk-soft »

hoangdiemtinh wrote: Mon May 20, 2024 5:33 am 7za.dll and 7zxa.dll work via COM interfaces.
But these DLLs don't use standard COM interfaces for objects creating.
What is the question?
7zip has no methods but standard call
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
Post Reply