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?
You call the function by typing its name and putting a value in parentheses. This value is sent to the function's parameter. e.g. We call the function firstFunction(“string as it's shown.”);
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);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With