You'll have to call LoadLibrary to get the module handle.
[DllImport("kernel32.dll")]
static extern IntPtr LoadLibrary(string lpFileName);
IntPtr moduleHandle = LoadLibrary("some.dll");
Note that you may combine LoadLibrary and DllImport for the same module.
[DllImport("some.dll")]
static extern int f(..);
....
IntPtr moduleHandle = LoadLibrary("some.dll"); //load some.dll
int i = f(..); // this call will attach to the already loaded dll
Willy.
scottt said:
What I am doing is trying to porting C++ code to C#.
In the C++ code one of the function calls uses the handle returned from
LoadLibrary() as a parameter. Since I am using the "DLLImport" I don't
have
that handl to pass into the function. I am looking for a way in C# to get
the
same handle as if I had called LoadLibrary().
Any suggestions on how I would get this.
And just as a follow up to my first question the
"Process.GetCurrentProcess().Handle" is not correct. To get the hWnd I
think
I need to do the following:
myForm.Handle.ToInt32()
Thanks.