C# 调用C++写的非托管DLL
1.接口函数所在动态库:LzCoUserClt4.dll。
2.接口方法:extern "C" int __declspec(dllexport) _GetUserID(char* szUserID)
3.调用举例:
CString strFileNamePath = _T(“LzCoUserClt4.dll”);
HMODULEhLib = LoadLibrary(strFileNamePath);
typedef int (*fun)(char*);
fun p = (fun)GetProcAddress(hLib,"_GetUserID");
if (p != NULL)
{
char szUserID[512];
memset(szUserID, 0, 512);
p(szUserID);
}
[DllImport(@"C:\Program Files\LiZheng\LzCoPlatClt(x64)\LzCoUserClt4.dll")]
public extern static int _GetUserID(string UserID);