> Thanks for your reply, but it doesn't work, I got this message,
> "Unhandled
> Exception: System.InvalidCastException: Cannot cast from source type to
> destination type."
Hmm, I just tested it with a DLL I quickly wrote, and it seems to work
alright. Where exactly do you get this exception?
> I want to know the different definition of these 2 C functions in C#, int
> MyFunc(int param1, MyStruct** param2); and int MyFunc(int param1,
> MyStruct*
> param2);, what is the different declaration in C#?
int MyFunc(int param1, MyStruct** param2);
becomes:
(with MyStruct being a C# class)
static extern int MyFunc(int param1, ref MyStruct param2);
(I don't know of a way to do this with MyStruct being a C# struct)
int MyFunc(int param1, MyStruct* param2);
becomes:
(with MyStruct being a C# class)
static extern int MyFunc(int param1, MyStruct param2);
(with MyStruct being a C# struct)
static extern int MyFunc(int param1, ref MyStruct param2);
So, you see, "class" adds one indirection (*), "ref" also does.
Of course, if you don't need to use param2 in your C# program or if you
only pass it to another unmanaged function as an opaque handle, you can
also use IntPtr or ref IntPtr.
Fabian
ZhangZQ - 22 Jul 2004 10:12 GMT
Thank you very much!
It works now, I am using ref IntPtr, that param2 is only to be passed to the
unmanaged code.
Regards,
ZhangZQ
> > Thanks for your reply, but it doesn't work, I got this message,
> > "Unhandled
[quoted text clipped - 29 lines]
>
> Fabian