Reputation: 842
I have a dynamic library (.dll
) written in C++ exporting a function I'd like to use in my C# applicaiton:
int SendText(void* pControl, char* sText);
How can I, given it takes a pointer to void?
Upvotes: 6
Views: 8894
Reputation: 7591
for void*
you can just use IntPtr
,
strings will work with the MarshalAs
attribute:
[DllImport("MyDll.dll", CharSet = CharSet.Ansi)]
public static extern int SendText(IntPtr pControl, [MarshalAs(UnmanagedType.LPStr)] string sText);
Upvotes: 13