Page 1 of 1

LoadLibrary() Question

Posted: Mon May 02, 2005 2:10 am
by Xombie
Is it feasible to use LoadLibrary() to open one or more dlls (ex, user32.dll or kernel32.dll) and keep them open for the entire life of the program? Also, can I store the addresses of multiple functions (found via IsFunction() calls) without worrying whether those addresses will change? Will this kill memory usage? Or will function addresses change during the life of the program? Or, does it not really affect speed much if I just continually OpenLibrary(), IsFunction() and CloseLibrary() every time I need to access the DLL function?

I'm trying to optimize for speed here so just wondering if it's an okay idea to open the library and leave them open while the program is running.

Posted: Mon May 02, 2005 4:02 am
by Derlidio
Guess who? :roll:

Under your PB installation folder, look for a "Library SDK" folder, and under that, look for a "DLL Importer" folder.
Read the Readme.txt file you'll find there. I think it shows a good way for accomplishing what you want :wink:

Best wishes...

- PJoe

Posted: Mon May 02, 2005 4:25 am
by Xombie
Hello again, Derlidio!

Thanks for the quick answer. However, will it work with user32.dll? In fact, I can't even seem to understand the instructions. Wouldn't I just point it to the DLL file I want to 'import' and let it make a definition for me? Not sure how that works. Also, I'm on a Windows XP system and I hope for my program to work with Windows 95+. Will it cause problems if I do this? I can't copy my user32.dll file and include it with my program.

Did you see that I put your unicode example to good use? viewtopic.php?t=14948

Thanks again for that help! I may try doing a lot more gadgets.

Posted: Mon May 02, 2005 4:55 am
by Derlidio
Yippe!

As far as I know, the DLL Importer creates a wrapper library that makes the functions of the DLL you import available like those WinAPI commands (with an underscore at the end of the name). So, this way you'll not need the openlibrary, callfunction, etc.

I've not used it yet, :oops: but decided to post the info cos it seemed to apply to your question.

About previous operating systems, I think you have nothing to fear. There is no need for packing a system library with your application (like sending user32.dll or kernel32.dll). Indeed, you should completelly avoid doing that! The only thing you have to concern is to be sure that the functions you're using are available (in the same libraries) on previous OS versions (some are not, so it would limitate your app to a minimum OS version).

About your question on the pointer issue, I also think you have nothing to fear. Once you have grabbed the address of a function (as an example)that address will be valid for the life period of your app (supposing you keep the libary open).

Best wishes...

- PJoe