Reputation: 15314
I am doing a dllImport on a C++ dll and I have the following signature. StackOverflow has been very helpful so far, so I thought I'd throw this one and see what I get.
Are there any gotchas that I should be worried about? This is my first time using dllimport.
I need to import the following to C#:
HANDLE FooInit(char* name); //name appears to be a string like "COM1"
int Foo1(HANDLE handle, const char** sentence); //sentence appears to be a string like "Hello World"
int Foo2(HANDLE handle, DWORD* val);
Thanks very much!
Upvotes: 0
Views: 1819
Reputation: 49179
Check out the P/Invoke Cheat Sheet (not complete, but a quick reference). char * usually becomes string. const char ** is trickier as I can't tell by looking at it whether it's a pointer to a single string or an array of strings.
Upvotes: 4
Reputation: 42577
At first glance, I would expect you'd use IntPtr for all of your parameters and the HANDLE return type, and int for Foo1 and Foo2's return values.
Upvotes: 0