P/Invoke problem

U

usunto_bryjamus

Hi,

Is it possible to set path to dll from which I import? The problem is
that if I know the path I can use it in DllImport attribute but I need
to parametrize this path (this parameter is read when application
starts). E.g.:

string dllPath = ...; // Read when app starts

....

[DllImport(dllPath)]
....
 
M

Mattias Sjögren

Is it possible to set path to dll from which I import?

Not really, but you can manually load the DLL from the correct path
using the LoadLibrary Win32 API before calling any of its exported
functions.


Mattias
 
U

usunto_bryjamus

Hi,

I tryed but didn't work. Maybe problem is in type of dll. Dll was
written in ANSI C in 16 bit mode (3'rd party which I have to use and
have no other choice).

I will try your suggestion once more. Thank you.
 
M

Mattias Sjögren

I tryed but didn't work. Maybe problem is in type of dll. Dll was
written in ANSI C in 16 bit mode (3'rd party which I have to use and
have no other choice).

OK so that's an entirely different problem. AFAIK you can't directly
load and call into a 16-bit DLL when running a 32-bit process. It
requires some thunking or IPC.


Mattias
 

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