Friday, 15 February 2013

delphi - How to put a relative path for a DLL statically loaded? -


I have a DLL in Delphi 7 / Windows XP, which I want to load in the host application on Windows permanently Delphi, too). I am using this line of code:

  process Prepare_HTML_Email (var mailmessage: tid message; constant fileadder, adstatel, alarms type: string); Stdcall; External DLL_ADDRESS; Where  DLL_ADDRESS  should be the location, DLL is  

. But at this point I have a problem, the host application is a service, so it's running in C: \ windows \ system32 , but I want to put DLL in another directory, not C: \ Windows \ System 32 \ / Code>. The "external" keyword does not allow it to conform with a function, it only accepts continuous expression, so how do I get the path of DLL?

First of all, you are not doing "static loading" anything. D stands for DLL dynamic ; All DLLs are dynamically connected, regardless of where static linking is involved in how to include DCU and OBJ files in your program. You can not link to a DLL statically.

You are talking about load-time dynamic linking , where the OS loads the DLL for you, because due to the functions listed in it run-time dynamic In opposing linking , where you want to call LoadLibrary , the import table of your program, when you define your work external Use the instructions, then you make an entry in the import table And as far as I know, meaningless relative path. Looks for the DLL on OS load time (and run time) using one. In general, this app has everything on its directory, current directory, system directory, Windows directory, and then the path environment variable.

In your case, the current directory and the system directory are the same place, and you have no control over them anyway. Do not put your DLL in Windows directory; Which already has enough stuff that is not related there.

Your best bet is to put your DLL in the same directory as you have inserted your service exe. If you do not want to, then you can put enough programs enough to bootstrap your program in a DLL in that program and then later with the LoadLibrary whatever personal DLL directory you want Are, can load everything.

You can add your DLL to a location and then add that directory to the path environment variable. This variable is a shared resource, however, before you change it, think twice about it.


No comments:

Post a Comment