DllImport attribute

G

Guest

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

where %ProgramFiles% - some DOS variable?
 
M

Mattias Sjögren

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
 
G

Guest

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();
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top