Is it possible to include DLLs ?

Just starting out? Need help? Post your questions and find answers here.
flashbob
User
User
Posts: 92
Joined: Sat May 11, 2024 4:04 pm

Is it possible to include DLLs ?

Post by flashbob »

Is it possible to include external DLLs similar to image files (see command IncludeBinary ) ?
I only want to deliver my program as a single file and images / external libraries should be included.
Thx!
User avatar
jacdelad
Addict
Addict
Posts: 2032
Joined: Wed Feb 03, 2021 12:46 pm
Location: Riesa

Re: Is it possible to include DLLs ?

Post by jacdelad »

Yes, you can include every type of you want to. You need to copy the included DLL to a temporary directory or you can load it from memory (there's code for that somewhere here, I just don't know where).
Good morning, that's a nice tnetennba!

PureBasic 6.21/Windows 11 x64/Ryzen 7900X/32GB RAM/3TB SSD
Synology DS1821+/DX517, 130.9TB+50.8TB+2TB SSD
Quin
Addict
Addict
Posts: 1135
Joined: Thu Mar 31, 2022 7:03 pm
Location: Colorado, United States
Contact:

Re: Is it possible to include DLLs ?

Post by Quin »

I typically do it with a DataSection and IncludeBinary, extracting to %TEMP%. For me it was an updater executable, not a DLL, but my code worked like:

Code: Select all

Temp$ = GetEnvironmentVariable("TEMP")
FileID = CreateFile(#PB_Any, Temp$ + #PS$ + "Updater.exe")
If Not FileID
  ; ...
EndIf
WriteData(FileID, ?Updater, ?EndUpdater - ?Updater)
CloseFile(FileID)
RunProgram(Temp$ + #PS$ + "Updater.exe", "", GetCurrentDirectory())
THen in my data section, I have:

Code: Select all

	Updater:
	IncludeBinary "Updater.exe"
	EndUpdater:
HTH
flashbob
User
User
Posts: 92
Joined: Sat May 11, 2024 4:04 pm

Re: Is it possible to include DLLs ?

Post by flashbob »

... ok, thanks for the example. I don't want to copy the file (DLL) to a temp directory. So I I'm looking for an example to load the dll directly into memory ...
morosh
Enthusiast
Enthusiast
Posts: 335
Joined: Wed Aug 03, 2011 4:52 am
Location: Beirut, Lebanon

Re: Is it possible to include DLLs ?

Post by morosh »

PureBasic: Surprisingly simple, diabolically powerful
Post Reply