Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个.dll用 C++ 编写的动态库 () 导出我想在我的 C# 应用程序中使用的函数:
.dll
int SendText(void* pControl, char* sText);
鉴于它需要一个指向 void 的指针,我该怎么做?
因为void*您可以使用IntPtr, 字符串将与MarshalAs属性一起使用:
void*
IntPtr
MarshalAs
[DllImport("MyDll.dll", CharSet = CharSet.Ansi)] public static extern int SendText(IntPtr pControl, [MarshalAs(UnmanagedType.LPStr)] string sText);