Code: Select all
dll7zip=OpenLibrary(#PB_Any, "7-zip32.dll")
If dll7zip
Prototype.l ProtoSevenZip(hWnd.l, szCmdLine.l, stOutput.l, dwSize.l = 0)
Global SevenZip.ProtoSevenzip = GetFunction(dll7zip, "SevenZip")
Prototype.l ProtoSevenZipCheckArchive(szFileName.p-ascii, iMode.l = 0)
Global SevenZipCheckArchive.ProtoSevenZipCheckArchive = GetFunction(dll7zip, "SevenZipCheckArchive")
else
debug "dll not found"
end
endif
Code: Select all
ImportDLL "7-zip32.dll
SevenZip(hWnd.l, szCmdLine.l, stOutput.l, dwSize.l = 0)
SevenZipCheckArchive(szFileName.p-ascii, iMode.l = 0)
ImportFail
debug "Dll not found"
end
ImportEnd
Code: Select all
ImportDLL "7-zip32.dll
SZ(hWnd.l, szCmdLine.l, stOutput.l, dwSize.l = 0) as "SevenZip"
SZCheckArchive(szFileName.p-ascii, iMode.l = 0) as "SevenZipCheckArchive"
ImportFail
debug "Dll not found"
end
ImportEnd
btw. something like this:
Code: Select all
procedure sevenzipfail(hWnd.l, szCmdLine.l, stOutput.l, dwSize.l = 0)
procedurereturn #false ; always return false, when dll doesn't exist
endprocedure
procedure sevenzipcheckarchivefail(szFileName.p-ascii, iMode.l = 0)
procedurereturn #false
endprocedure
ImportDLL "7-zip32.dll"
SZ(hWnd.l, szCmdLine.l, stOutput.l, dwSize.l = 0) as "SevenZip" onfail @sevenzipfail()
SZCheckArchive(szFileName.p-ascii, iMode.l = 0) as "SevenZipCheckArchive" onfail @sevenzipcheckarchivefail()
ImportFail
debug "Some function will not work without 7-zip.dll"
ImportEnd
when the import fails, it should use the given procedure instead. So the dll is optional for running the program.