dllimport problem

G

Guest

greentings

I have a unmanaged dll that I need to use on my C# app. The problem is that
the dll may be in diferent places... The only way I have to get the location
of the dll is getting a key on the registry.

How can I use dllimport to a variable location?
or
There is another way to do this task?

I just need to load some methods from the dll...

Thanks in advance
 
T

Tom Spink

Diogo said:
greentings

I have a unmanaged dll that I need to use on my C# app. The problem is
that the dll may be in diferent places... The only way I have to get the
location of the dll is getting a key on the registry.

How can I use dllimport to a variable location?
or
There is another way to do this task?

I just need to load some methods from the dll...

Thanks in advance
Hi,

How can I use dllimport to a variable location?
Unfortunately you cannot (not at runtime).
There is another way to do this task?
Yes.. but it's quite a lot more involved. It requires you to use the
LoadLibrary API to dynamically load the DLL into memory, then locate the
entry-point of the function(s) you require.

Once you have the addresses of the entry points, you then need to invoke
them, something I'll admit I don't know how to do in C#, having only done
this using C++.

Nothing creative immediately springs to mind, however I'm sure a quick
Google (and the help of Windows experts in this group!) will help with
that.
 

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

Similar Threads


Top