I know this has been asked before, but it seems that it has NOT been answered yet.
Say I have a DLL file in which i would like to use one or more of its functions in my Pure Basic Program. What I would like to do is somehow incorporate this DLL or just the functions that I will be using into the exe that Pure Basic creates without having to extract or distribute any files other than the exe.
I played around with the Import DLL program in the Library SDK folder of Pure Basic, but it only went half way. It let me use the DLL just like you can the functions from win32.dll (ie: SendMessageA_(option1,option2,etc)) without first declaring and loading the library manually; however the program STILL needs the DLL in order to run.
Maybe there is a way to convert a DLL to a static library that Pure Basic can use kind of like how the UserLibraries work right now?
Or maybe there is a way to add the DLL as a resource in the exe and use a pointer to point to the DLL functions in MEMORY?
Thanks in advance,
Zodmare
zodmare@hotmail.com
DLL functions without distro of DLL files?
win32.dll (ie: SendMessageA_(option1,option2,etc)) = Windows API, can be used directly from within PB, but if you have a dll and you didn't create it i suggest the folowing workaround.
This way you binaryinclude teh dll u wanted to use and extract it to a secretlocation e.g. systemdir and call the dll from there, on program exit delete the dll...
Code: Select all
Procedure ExpandDLL()
;SystemDir=SystemDirectory()
;If SystemDir>""
If Right(SystemDir,1) = "\"
Location = DirectorytoExtract (Example SYSTEMDIR or WINDOWSDIR)
Else
Location = DirectorytoExtract
EndIf
If CreateFile(1, Location) ;
UseFile(1)
L1= ?ExitProc-?Inc
WriteData(?Inc,L1)
CloseFile(1)
EndIf
ProcedureReturn 1
Inc:
IncludeBinary "Dllfilename..."
ExitProc:
EndProcedure
Re: DLL functions without distro of DLL files?
Good programmers don't comment their code. It was hard to write, should be hard to read.
I use PEBundle
This small tool let me extract dlls into memory and call it from there without writing it to the HD.
Your code dosen't have to be changed at all, PEBundle does the job. You only compile you file as usuall and then use PEBundle to bundle the dll and choose the option to not extract to disk and thats all!!

As an example, i distribute in this forum a running example of my dll. The dll is bundled to the executable and it runs fine.
http://www.getafile.com/cgi-bin/merlot/ ... xample.zip
The only problems found (and resolved) was with the COM (not the dll that was bundled) because i compress them.
Why didn't i bundle the COM objects too?
Because since it need to be registered to run, it can't be runed from memory.
Normal dlls works 100% with PEBundle.
http://www.collakesoftware.com/PEBundle/CSPEBundle.htm
This small tool let me extract dlls into memory and call it from there without writing it to the HD.
Your code dosen't have to be changed at all, PEBundle does the job. You only compile you file as usuall and then use PEBundle to bundle the dll and choose the option to not extract to disk and thats all!!
As an example, i distribute in this forum a running example of my dll. The dll is bundled to the executable and it runs fine.
http://www.getafile.com/cgi-bin/merlot/ ... xample.zip
The only problems found (and resolved) was with the COM (not the dll that was bundled) because i compress them.
Why didn't i bundle the COM objects too?
Because since it need to be registered to run, it can't be runed from memory.
Normal dlls works 100% with PEBundle.
http://www.collakesoftware.com/PEBundle/CSPEBundle.htm
ARGENTINA WORLD CHAMPION
-
- Enthusiast
- Posts: 229
- Joined: Wed May 14, 2003 3:38 pm
- Location: Lüneburg - Germany
-
- Enthusiast
- Posts: 229
- Joined: Wed May 14, 2003 3:38 pm
- Location: Lüneburg - Germany
Yep, newer version seems to offer register COM, i have an older one.FloHimself wrote:@ricardo
What version of PBBundle do you use? Seems that the newer version has support to register COMs!?
@zodmare
You just develope you application as usuall, at the end use PEBundle at this tool does everything, you don't have to code anything 'different'. PEBundle resolves the comunication betwen you executable and the dll
ARGENTINA WORLD CHAMPION
There is a tool to convert DLLs to static libraries:
http://www.binary-soft.com/dll2lib/dll2lib.htm
Haven't tried it yet (as it costs $99). So I can't say whether it works or not.
Have a nice day!
[/quote]
http://www.binary-soft.com/dll2lib/dll2lib.htm
Haven't tried it yet (as it costs $99). So I can't say whether it works or not.
Have a nice day!
