It is currently Sat May 25, 2013 1:30 am

All times are UTC + 1 hour




Post new topic Reply to topic  [ 6 posts ] 
Author Message
 Post subject: ImportDLL
PostPosted: Sat Oct 22, 2011 4:52 pm 
Offline
PureBasic Expert
PureBasic Expert

Joined: Fri Apr 25, 2003 6:41 pm
Posts: 1125
Now:
Code:
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


possible alternate:
Code:
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


or

Code:
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


i Know, that a Import-Command exist, but when i don't have a .lib file, i can't use it.

btw. something like this:
Code:
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

would be nice.

when the import fails, it should use the given procedure instead. So the dll is optional for running the program.


Top
 Profile  
 
 Post subject: Re: ImportDLL
PostPosted: Sat Oct 22, 2011 6:29 pm 
Offline
Addict
Addict

Joined: Tue May 06, 2003 5:07 pm
Posts: 2258
Location: UK
You actually already can do this, on windows, if you have a provided .lib file with the DLL. However I pretty much agree with your request, it'd be handy on all platform to have a function like that!


Top
 Profile  
 
 Post subject: Re: ImportDLL
PostPosted: Sat Oct 22, 2011 6:34 pm 
Offline
PureBasic Expert
PureBasic Expert

Joined: Fri Apr 25, 2003 6:41 pm
Posts: 1125
GPI wrote:
i Know, that a Import-Command exist, but when i don't have a .lib file, i can't use it.


:)

The second problem is, that the DLL isn't optional, when you use the import-command with a lib.


Top
 Profile  
 
 Post subject: Re: ImportDLL
PostPosted: Sat Oct 22, 2011 6:58 pm 
Offline
Addict
Addict

Joined: Tue May 06, 2003 5:07 pm
Posts: 2258
Location: UK
Oops sorry, I should stop reading quickly!! :)


Top
 Profile  
 
 Post subject: Re: ImportDLL
PostPosted: Sun Oct 23, 2011 1:09 am 
Offline
Addict
Addict

Joined: Fri Apr 25, 2003 11:10 pm
Posts: 852
hi GPI
you can make a lib file for a dll in PellesC, just type:
if 32-bit
polib yourdll.dll /machine:x86 /out:yourdll.lib
if 64-bit
polib yourdll.dll /machine:x64/out:yourdll.lib


Top
 Profile  
 
 Post subject: Re: ImportDLL
PostPosted: Sun Oct 23, 2011 11:58 am 
Offline
Addict
Addict
User avatar

Joined: Wed Aug 31, 2005 11:09 pm
Posts: 2241
Location: Italy
jack wrote:
hi GPI
you can make a lib file for a dll in PellesC, just type:
if 32-bit
polib yourdll.dll /machine:x86 /out:yourdll.lib
if 64-bit
polib yourdll.dll /machine:x64/out:yourdll.lib


I had some problems in the past doing that for 64 bit, then I solved in some way...

Maybe I did something wrong, not sure, but I saw the problem reported by other people too.

This is the thread if can be useful in some way: viewtopic.php?p=273865#p273865

_________________
[ Home ] [ My PC ] [ New to PB ? ]


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye