DllImport attribute

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

How I can write somthing like this:
[DllImport("%ProgramFiles%\\aaa.dll")]

where %ProgramFiles% - some DOS variable?
 
How I can write somthing like this:
[DllImport("%ProgramFiles%\\aaa.dll")]

where %ProgramFiles% - some DOS variable?

You can't. What you can do instead is is to just use
[DllImport("aaa.dll")], and then explicitly load the DLL with
LoadLibrary before using it.


Mattias
 
How I can write somthing like this:
[DllImport("%ProgramFiles%\\aaa.dll")]

where %ProgramFiles% - some DOS variable?

You can't. What you can do instead is is to just use
[DllImport("aaa.dll")], and then explicitly load the DLL with
LoadLibrary before using it.

Oh! Sorry for stupid question... Can you show me how I can do this?
Something like this doesn't work correct...

[DllImport("kernel32.dll")]
static extern IntPtr LoadLibrary(string lpFileName);

[DllImport("aaa.dll")]
static extern void bbb();

void main()
{
IntPtr lib = LoadLibrary("C:\\Program Files\\...Some path...\\aaa.dll");
bbb();
}
 
Back
Top