DLL functions without distro of DLL files?

Just starting out? Need help? Post your questions and find answers here.
zodmare
New User
New User
Posts: 3
Joined: Tue Apr 29, 2003 11:43 pm

DLL functions without distro of DLL files?

Post by zodmare »

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
darklordz
Enthusiast
Enthusiast
Posts: 119
Joined: Wed May 21, 2003 1:44 pm
Location: Netherlands
Contact:

Post by darklordz »

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.

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
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...
traumatic
PureBasic Expert
PureBasic Expert
Posts: 1661
Joined: Sun Apr 27, 2003 4:41 pm
Location: Germany
Contact:

Re: DLL functions without distro of DLL files?

Post by traumatic »

Good programmers don't comment their code. It was hard to write, should be hard to read.
ricardo
Addict
Addict
Posts: 2438
Joined: Fri Apr 25, 2003 7:06 pm
Location: Argentina

Post by ricardo »

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!!

Image

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
FloHimself
Enthusiast
Enthusiast
Posts: 229
Joined: Wed May 14, 2003 3:38 pm
Location: Lüneburg - Germany

Post by FloHimself »

@ricardo
What version of PBBundle do you use? Seems that the newer version has support to register COMs!?
zodmare
New User
New User
Posts: 3
Joined: Tue Apr 29, 2003 11:43 pm

Post by zodmare »

Ive downloaded PEBundle before, i bundled the exe and a dll. But I was not sure on how to use the dll while bundled. Could someone please show me an example in Pure Basic of how to use a dll that was combined with an exe using the advanced method of PEBundle?

thanks,
zodmare
FloHimself
Enthusiast
Enthusiast
Posts: 229
Joined: Wed May 14, 2003 3:38 pm
Location: Lüneburg - Germany

Post by FloHimself »

You don't have to handle this by yourself. Just use the DLL as always in your PB Code.. After compiling to exe you must have the DLL in your application path, where your exe is.
Now you just bundle it with PEBundle. After that you can simply delete/remove the DLL from that path.
ricardo
Addict
Addict
Posts: 2438
Joined: Fri Apr 25, 2003 7:06 pm
Location: Argentina

Post by ricardo »

FloHimself wrote:@ricardo
What version of PBBundle do you use? Seems that the newer version has support to register COMs!?
Yep, newer version seems to offer register COM, i have an older one.

@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
javabean
User
User
Posts: 60
Joined: Sat Nov 08, 2003 10:29 am
Location: Austria

Post by javabean »

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! :D[/quote]
Post Reply