Page 1 of 1

[Solved] OpenLibrary fails without DLL file extension

Posted: Thu Feb 20, 2020 8:47 am
by BarryG
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!

Re: OpenLibrary fails without DLL file extension

Posted: Thu Feb 20, 2020 3:58 pm
by Paul
Works fine here ;)
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

Posted: Fri Feb 21, 2020 12:27 am
by BarryG
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

Posted: Fri Feb 21, 2020 4:18 am
by Paul
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.

Re: OpenLibrary fails without DLL file extension

Posted: Fri Feb 21, 2020 4:23 am
by BarryG
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.

Re: OpenLibrary fails without DLL file extension

Posted: Fri Feb 21, 2020 6:09 am
by chi
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.

Re: OpenLibrary fails without DLL file extension

Posted: Fri Feb 21, 2020 6:42 am
by BarryG
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].