C++ .h文件
VIDEO_DLL_API int __cdecl PlatformQueryRes(char* pcSvrIpAddress, char *pcLoginUserName, char** ppcResult);
C++ .cpp文件
int __cdecl PlatformQueryRes(char* pcSvrIpAddress, char *pcLoginUserName, char** ppcResult)
{
if (!g_Global.m_bInitPlatformSDKFlag)
{
return Platform_ErrUnInit;
}
if (NULL == pcSvrIpAddress || NULL == pcLoginUserName || NULL == ppcResult)
{
return Platform_ErrInvalidParam;
}
string sResult;
PlatformBase_ptr ptrPlatformBase = g_Global.GetPlatformObject(pcSvrIpAddress);
if (ptrPlatformBase.get())
{
int iResult;
iResult = ptrPlatformBase->QueryRes(pcLoginUserName, sResult);
if (iResult == Platform_ErrSuccess)
{
strcpy(*ppcResult, (char*)sResult.c_str());
}
if (iResult == Platform_ErrQueryFail)
{
strcpy(*ppcResult, "");
}
return iResult;
}else
{
return Platform_ErrQueryFail;
}
}
C# .cs文件
public extern static int PlatformQueryRes(byte[] pcSvrIpAddress, byte[] pcLoginUserName, ref StringBuilder ppcResult);
ref StringBuilder与char**相对应。
C#调用C++ DLL 传出字符串时,C++ DLL相应接口的传出字符串参数为char**。