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.
.dllC#アプリケーションで使用したい関数をエクスポートする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);