Re: Late binding with unmanaged code
- From: "scott blood" <scott_blood@xxxxxxxxxxx>
- Date: Thu, 16 Mar 2006 11:01:48 -0000
hello,
My Apologies i ommited a number of import calls, was too busy drinking my
morning brew.
[DllImport("kernel32")]
public extern static IntPtr LoadLibrary(string lpLibFileName);
[DllImport("kernel32")]
public extern static Int32 FreeLibrary(IntPtr hModule);
I cant off the top of my head remember where GetProcAadress comes from, i
think it is Kernal32.
I wonder can someone else show an example of importing GetProcAddress
Regards
Scott Blood
C# Developer
"Entwickler" <Entwickler@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:76757E11-EB5B-4194-A5DD-9CA1524E84B9@xxxxxxxxxxxxxxxx
Hello scott,
thank you for your reply. i am trying to apply the code you send but it is
looking like i am missing a namespace . when i try to compile i become the
following errors :
"The name 'LoadLibrary' does not exist in the current context"
"The name 'GetProcAddress' does not exist in the current context"
i am using the following namespaces :
using System.Reflection.Emit;
using System.Reflection;
using System.Runtime.InteropServices;
I don't know if i am missing a namespace .
thanks.
"scott blood" wrote:
Hello,
Unfortunatly you cannot call unmanaged code using late binding in this
method.
Please review the following code which should help you
[DllImport("Invoke", CharSet=CharSet.Unicode)]
public extern static int InvokeFunc(int funcptr, int hwnd, string
message,
string title, int flags);
int hmod=LoadLibrary("MyLib.dll");
int funcaddr=GetProcAddress(hmod, "MyFunction");
int result=InvokeFunc(funcaddr, 0, "Hello World", ".test", 1);
FreeLibrary(hmod);
Regards
Scott Blood
C# Developer
"Entwickler" <Entwickler@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:3611B442-44D6-4AFF-9E25-A0C8415B0413@xxxxxxxxxxxxxxxx
hello,
i have the following problem. i want to write a code that enables the
user
to call functions from a unmanaged code .dll at running time . so i
have
to
use the late binding . i tried the following code but it doesn't walk :
Assembly assemblyInstance =
Assembly.LoadFrom(@"C:\myData\UnmanagedCode.dll");
i don't know if somebody can help me .
Regards,
.
- References:
- Re: Late binding with unmanaged code
- From: scott blood
- Re: Late binding with unmanaged code
- Prev by Date: Binding a TextBox to a particular cell of an Access database table
- Next by Date: Re: Assemlby.LoadForm() exception
- Previous by thread: Re: Late binding with unmanaged code
- Next by thread: Re: Late binding with unmanaged code
- Index(es):
Relevant Pages
|