Just got a bug report today from a customer who said a specific feature of my app was no longer working since my last update. After checking, I discovered OpenLibrary doesn't work with filenames that don't end with ".DLL", which seems a weird requirement. Would this be a Windows or PureBasic enforcement?
If it's a PureBasic thing, then I would like to request that it works with the file given to it, and not fail if that file doesn't specifically end in ".DLL", just like LoadImage will open a picture file that doesn't have an extension. Thanks!
[Solved] OpenLibrary fails without DLL file extension
[Solved] OpenLibrary fails without DLL file extension
Last edited by BarryG on Fri Feb 21, 2020 6:43 am, edited 1 time in total.
Re: OpenLibrary fails without DLL file extension
Works fine here 
Maybe you have some other issue?
Compile this as DLL named "mydll.xxx"
Run this code...

Maybe you have some other issue?
Compile this as DLL named "mydll.xxx"
Code: Select all
ProcedureDLL MyFunction()
MessageRequester("Hello", "This is a PureBasic DLL !", 0)
EndProcedure
Run this code...
Code: Select all
If OpenLibrary(0, "mydll.xxx")
CallFunction(0, "MyFunction")
CloseLibrary(0)
EndIf
Re: OpenLibrary fails without DLL file extension
Paul, you're still using an extension, though. Rename your DLL to just "MyDLL" (no extension) and you'll see it doesn't work.
Re: OpenLibrary fails without DLL file extension
LOL...
you said "OpenLibrary doesn't work with filenames that don't end with ".DLL"
You didn't say you wanted the DLL to have no extension at all
So in that case, YES, OpenLibrary requires the file to have some type of extension.
you said "OpenLibrary doesn't work with filenames that don't end with ".DLL"
You didn't say you wanted the DLL to have no extension at all

So in that case, YES, OpenLibrary requires the file to have some type of extension.
Re: OpenLibrary fails without DLL file extension
True, but the question still remains: I wonder if this is a PureBasic requirement for OpenLibrary()? I have a bunch of support files without extensions, and this means I can't use the DLL at the moment, without showing it's a DLL due to the required extension. This in turn causes support issues because a few users run cleaning apps that delete "orphan" DLLs like that, because the DLL file alone in my directory and not loaded in memory all the time. So I need to stop those apps deleting it by mistake.
I'm hoping OpenLibrary() can be amended to act like LoadImage() and just read the specified file as presented.
I'm hoping OpenLibrary() can be amended to act like LoadImage() and just read the specified file as presented.
Re: OpenLibrary fails without DLL file extension
LoadLibrary_(...) wrote:If the string specifies a module name without a path and the file name extension is omitted, the function appends the default library extension .dll to the module name. To prevent the function from appending .dll to the module name, include a trailing point character (.) in the module name string.
Et cetera is my worst enemy
Re: OpenLibrary fails without DLL file extension
Thank you, chi - appending a single dot to the extensionless DLL filename does the job! And good to see it was a Windows thing and not PureBasic requirement. I can consider this request [Solved].