C#如何调用C DLL呢?
C#如何调用C DLL呢? MSDN文档有说的using System.Runtime.InteropServices;
public static extern IntPtr ImmGetContext( IntPtr hWnd );
public static extern IntPtr ImmAssociateContext( IntPtr hWnd, IntPtr hIMC );
static extern int ImmGetCompositionString( IntPtr hIMC, int dwIndex, StringBuilder lpBuf, int dwBufLen );
诸如这种方式吧 给你来个实例
public static extern bool CloseHandle( IntPtr hObject ); 如果C函数传递,或者返回字符串指针,C#如何调用?
假设C函数:
extern "C" DLL_EXTERNCHAR *__stdcall get_str(void);
extern "C" DLL_EXTERNvoid __stdcall set_str(CHAR *);
extern "C" DLL_EXTERNCHAR *__stdcall get_set_str(CHAR *);
C#如何调用? C# 有个 System.Runtime.InteropServices.Marshal类
专处理兼容C++传过来的指针资料。
或者开unsafe模式也可以用指针。
页:
[1]