Author |
Topic: XZIP DLL (Read 155 times) |
|
PabloSGL
New Member
member is offline


Posts: 5
|
 |
Re: XZIP DLL
« Reply #2 on: Feb 16th, 2018, 5:11pm » |
|
Part III
Code:
'------------ COM and XZip.dll subs/functions ----------
[InitCom]
Struct comObj, obj As Ulong 'for receiving pointers to COM objects
Struct LVAL, x As Long 'for receiving numeric returns from COM methods
Struct STRVAL, x As Ptr 'for receiving string returns from COM methods
Return
Sub Zip.Pack XZipObject, src$, zip$
Calldll #com, "dhCallMethod", XZipObject As Ulong, ".Pack(%s, %s)" As Ptr,_
src$ As Ptr, zip$ As Ptr, r As Long
End Sub
Sub Zip.Pack.PreservePath XZipObject, src$, zip$
Calldll #com, "dhCallMethod", XZipObject As Ulong, ".Pack(%s, %s, %d)" As Ptr,_
src$ As Ptr, zip$ As Ptr, 1 As Long, r As Long
End Sub
Sub Zip.UnPack XZipObject, zip$, destination$
Calldll #com, "dhCallMethod", XZipObject As Ulong, _
".UnPack(%s, %s)" As Ptr, zip$ As Ptr, destination$ As Ptr, r As Long
End Sub
Sub Zip.Delete XZipObject, file$, zip$
Calldll #com, "dhCallMethod", XZipObject As Ulong, ".Delete(%s, %s)" As Ptr,_
file$ As Ptr, zip$ As Ptr, r As Long
End Sub
Sub ShowZipFiles XZipObject, hList, zipFile$
'Display a list of the files contained in the zip file
'along with their uncompressed size and any stored path.
'Display the files in a listview control.
tFolder = 1
tFile = 2
Call ListView.DeleteAllItems hList
Calldll #com, "dhGetValue", "%o" As Ptr, comObj As Struct, _
XZipObject As Ulong, ".Contents(%s)" As Ptr, zipFile$ As Ptr, r As Long
objItems = comObj.obj.struct: comObj.obj.struct = 0
count = GetValueLong(objItems, ".Count")
For Idx = 1 To count
Calldll #com, "dhGetValue", "%o" As Ptr, comObj As Struct, _
objItems As Ulong, ".Item(%d)" As Ptr, Idx As Long, r As Long
objItem = comObj.obj.struct: comObj.obj.struct = 0
If GetValueLong(objItem, ".Type") = tFile Then
listIdx = listIdx + 1
fileName$ = GetValueStr$(objItem, ".Name")
fileTime$ = GetValueDateTime$(objItem, ".Date")
fileSize = GetValueLong(objItem, ".Size")
filePath$ = GetValueStr$(objItem, ".Path")
r = ListView.InsertItem(hList, listIdx-1, 0, fileName$)
r = ListView.SetItem(hList, listIdx-1, 1, fileTime$)
r = ListView.SetItem(hList, listIdx-1, 2, Str$(fileSize))
r = ListView.SetItem(hList, listIdx-1, 3, filePath$)
End If
Call SetNothing objItem
Next Idx
Call SetNothing objItems
End Sub
Function GetArchiveFileCount(XZipObject, zipFile$)
Calldll #com, "dhGetValue", "%o" As Ptr, comObj As Struct, _
XZipObject As Ulong, ".Contents(%s)" As Ptr, zipFile$ As Ptr, r As Long
objItems = comObj.obj.struct: comObj.obj.struct = 0
GetArchiveFileCount = GetValueLong(objItems, ".Count")
Call SetNothing objItems
End Function
Sub BeginCOM
Open "oleaut32.dll" For Dll As #ole
Open "LB_dispHelper.dll" For Dll As #com
Calldll #com, "dhInitializeCom", FALSE As Long, r As Long
Calldll #com, "dhToggleExceptions", 1 As Long, r As Long
End Sub
Sub EndCOM
Close #ole
Calldll #com, "Uninitialize_COM", 1 As Long, r As Void
Close #com
End Sub
Function CreateObject(ObjName$)
'Create an instance of ObjName$ on the local machine
ObjName$ = ObjName$ + Chr$(0)
Calldll #com, "dhCreateObject", ObjName$ As Ptr, _NULL As Long, _
comObj As Struct, r As Ulong
CreateObject = comObj.obj.struct: comObj.obj.struct = 0
End Function
Sub SetNothing Object
Calldll #com, "dhReleaseObject", Object As Ulong, r As Void
End Sub
Function GetValueStr$(Object, item$)
STRVAL.x.struct = ""
Calldll #com, "dhGetValue", "%s" As Ptr, STRVAL As Struct, _
Object As Ulong, item$ As Ptr, r As Long
GetValueStr$ = Winstring(STRVAL.x.struct)
x=STRVAL.x.struct: Calldll #com, "FreeString", x As Ulong, r As Void
End Function
Function GetValueLong(Object, item$)
LVAL.x.struct = 0
Calldll #com, "dhGetValue", "%d" As Ptr, LVAL As Struct, _
Object As Ulong, item$ As Ptr, r As Long
GetValueLong = LVAL.x.struct
End Function
Function GetValueDateTime$(Object, item$)
TIME.NOSECONDS = 2
Struct DT, x As Double
Struct st, _ 'SYSTEMTIME
wYear As Word, _
wMonth As Word, _
wDayOfWeek As Word, _
wDay As Word, _
wHour As Word, _
wMinute As Word, _
wSecond As Word, _
wMilliseconds As Word
Calldll #com, "dhGetValue", "%D" As Ptr, DT As Struct, _
Object As Ulong, item$ As Ptr, r As Long
vtDate = DT.x.struct
Calldll #ole, "VariantTimeToSystemTime", vtDate As Double, st As Struct, r As Long
dtBuf$ = Space$(50)
Calldll #kernel32, "GetDateFormatA", LOCALE_SYSTEM_DEFAULT As Ulong, _
_NULL As Ulong, st As Struct, _NULL As Ulong, dtBuf$ As Ptr, 50 As Long, _
dt$ = Left$(dtBuf$,r-1)
dtBuf$ = Space$(50)
Calldll #kernel32, "GetTimeFormatA", LOCALE_SYSTEM_DEFAULT As Ulong, _
TIME.NOSECONDS As Ulong, st As Struct, _NULL As Ulong, dtBuf$ As Ptr, 50 As Long, _
r As Long
tm$ = Left$(dtBuf$,r-1)
GetValueDateTime$ = dt$ + " " + tm$
End Function
|
|
Logged
|
|
|
|
PabloSGL
New Member
member is offline


Posts: 5
|
 |
Re: XZIP DLL
« Reply #3 on: Feb 16th, 2018, 5:15pm » |
|
I get this error "Missing AS in CALLDLL". If somebody can make this to work I will be eternally grateful
Thank you.
Best regards,
- Pablo Sighel
|
|
Logged
|
|
|
|
Richard Russell
Administrator
member is offline


Posts: 1348
|
 |
Re: XZIP DLL
« Reply #4 on: Feb 16th, 2018, 6:31pm » |
|
on Feb 16th, 2018, 5:11pm, PabloSGL wrote: Code: dtBuf$ = Space$(50)
Calldll #kernel32, "GetDateFormatA", LOCALE_SYSTEM_DEFAULT As Ulong, _
_NULL As Ulong, st As Struct, _NULL As Ulong, dtBuf$ As Ptr, 50 As Long, _
dt$ = Left$(dtBuf$,r-1) |
|
According to your comments you changed the Windows Constant to LOCALE.SYSTEM.DEFAULT (dots) but here it still has underscores. Did you change it using Edit... Replace... Replace all? That should have replaced all occurrences in the program, so I don't understand how these were missed.
Richard.
|
|
Logged
|
|
|
|
PabloSGL
New Member
member is offline


Posts: 5
|
 |
Re: XZIP DLL
« Reply #5 on: Feb 16th, 2018, 8:51pm » |
|
Oops!, sorry!!!
I did not see the difference between _LOCALE_SYSTEM_DEFAULT and LOCALE.SYSTEM.DEFAULT (the DOTs)
You know what they say:"BASIC programmers are blind, because they can´t C"
FIXED! Thanks!!!
- Pablo
|
|
Logged
|
|
|
|
Richard Russell
Administrator
member is offline


Posts: 1348
|
 |
Re: XZIP DLL
« Reply #6 on: Feb 16th, 2018, 9:22pm » |
|
on Feb 16th, 2018, 8:51pm, PabloSGL wrote:| I did not see the difference between _LOCALE_SYSTEM_DEFAULT and LOCALE.SYSTEM.DEFAULT |
|
It's a peculiarity of Liberty BASIC that underscores are legal in Windows constants but not in variable names, whereas dots are legal in variable names but not in Windows constants (at least, there are no Windows constants containing dots).
I think you can claim the prize for discovering the first Windows constant that is known about by LB 4 but not by LBB. When creating LBB I had to 'guess' which constants to include and which not to include, and when there is a difference it is usually the other way around (i.e. LBB knows about it but LB 4 doesn't).
Sadly for you, there isn't really a prize! Sorry.
Richard.
|
|
Logged
|
|
|
|
|