Wah!!! great, you are really an expert.
"Chris Taylor" <chris_taylor_za@hotmail.com> wrote in message
news:%23R9dX41nDHA.3504@TK2MSFTNGP11.phx.gbl...
> Hi,
>
> If you are going to bind statically to the function then you could use
> interop aka P/Invoke from the System.Runtime.InteropServices name space.
>
> [DllImport("dllname.dll")]
> public int Add( int a, int b );
>
> If you want to do this dynamically it is a little more work, I believe
there
> is a solution using the Relection Emit however I would rather want to test
> this before commiting to it here :). But in principal, an I believe this
> should answer your other post as well. You could use the Reflection
classes
> to create a temporary Assembly that can use interop to load the function
and
> use the Reflection Emit to create a .NET function which would perform the
> actual invocation of the method. Being 5:31 in the morning I might just be
> dreaming here but if I get a chance I will give it a try and post my
> results.
>
> The following is a more hardcoded approach to what I am suggesting, it
might
> get you going
>
http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&oe=UTF-8&selm=ueqNoUdtCHA.2540%40TK2MSFTNGP10
>
> Cheers
>
> Chris Taylor
>
> "ZhangZQ" <zhangzq71@hotmail.com> wrote in message
> news:uY6Tsu1nDHA.3024@tk2msftngp13.phx.gbl...
> > Thanks,
> >
> > In C the GetProcAddress can get the function pointer, for example
> >
> > typedef int (*MYADD)(int, int);
> > MYADD add = (MYADD) GetProcAddress(hMyLib, "add");
> >
> > but how to pass the function pointer to that delegate?
> >
> >
> > Thank you very much again!
> >
> >
> >
> >
> > "Chris Taylor" <chris_taylor_za@hotmail.com> wrote in message
> > news:Of5RPn1nDHA.2592@TK2MSFTNGP10.phx.gbl...
> > > Hi,
> > >
> > > You would use a delegate.
> > >
> > > delegate int AddCallback( int a, int b );
> > >
> > > Hope this helps
> > >
> > > Chris Taylor
> > >
> > > "ZhangZQ" <zhangzq71@hotmail.com> wrote in message
> > > news:eNOeZg1nDHA.2432@TK2MSFTNGP10.phx.gbl...
> > > > if there is a function in a win32 dll, it is definition is
> > > >
> > > > int add(int a, int b);
> > > >
> > > >
> > > > how to define that function pointer in C#?
> > > >
> > > >
> > > > thank you very much!
> > > >
> > > >
> > >
> > >
> >
> >
>
>