• 0

[DELPHI] Loading unknown DLLs at runtime


Question

I am writing a plugin system in Delphi. My initial choice was a DLL-based system and I would still like to carry it through, but I've discovered that both the external overload and LoadLibrary function only work with constant values, so I cannot use them unless I know the name of the DLLs at designtime - which of course I don't. I've found several solutions but they are all so old they either don't work on 2000/XP or need Delphi 5 (I am using Delphi 7)! I've found Dragonsoft's plugin program too but it's not what I want. I just need a way to get DLLs at runtime, nothing else.

What can I do?

Link to comment
Share on other sites

3 answers to this question

Recommended Posts

  • 0

It's been a while since I used Delphi. IIRC, you need to cast to PChar to call LoadLibrary. Is there not a constant equivalent?

Off the top of my head, one thing you COULD do is write a small C++ DLL that you can call that calls LoadLibrary and returns the HINSTANCE to you.

Link to comment
Share on other sites

  • 0

Dear god, it worked! :D

Only problem now is that I'm getting the unsafe type warning which I'm trying to avoid. Is there any way to get around pChar, too?

Link to comment
Share on other sites

  • 0

Oh, you're using managed Delphi. Didn't realize. In that case, you could use the Marshal class to marshal the string to an unmanaged char pointer, rather than using PChar.

Link to comment
Share on other sites

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.