STDMETHODIMP CVXNAgent::VXNGetData( BSTR* pbstrOutData)
{
*pbstrOutData = SysAllocString(_T("0"));
}
SysAllocString的定义
BSTR SysAllocString(
OLECHAR FAR* sz
);
注意
BSTR bstr = ::SysAllocString(L"My BSTR");
可以
但是
void __stdcall GetString(/*[out]*/ BSTR* pBstrReceiver)
{
*pBstrReceiver = L"My BSTR";
}不行,因为字符串的长度不对
STDMETHODIMP CVXNAgent::VXNGetData( BSTR* pbstrOutData)
{
CString csVersionDesc, csDesc;
csDesc.LoadString(g_hInstance, IDS_VERSION_DESC);
csVersionDesc.Format(VPN_FORMAT_VERSION_DESC, csDesc, csBuildTime);
DbgOutput(VXN_INFO_TYPE_SUCCESS, _T("VXNAgent模块,版本描述:%s"), csDesc);
DbgOutput(VXN_INFO_TYPE_SUCCESS, _T("VXNAgent模块,编译时间:%s"), csBuildTime);
//输出参数赋值
if(pbstrVersionDesc)
{
*pbstrVersionDesc = csVersionDesc.AllocSysString();
}
}
STDMETHODIMP CVXNAgent::VXNGetData( BSTR* pbstrOutData)
{
HardwareInfo hardwareinfo;
DWORD dwrunip = hardwareinfo.GetRunIP(BoxIP);
unsigned char *b;
b=(unsigned char *)&dwrunip;
char a[32];
_snprintf_s(a,32,"%u.%u.%u.%u",b[0],b[1],b[2],b[3]);
CComBSTR aa = a;
aa.CopyTo(pbstrOutData);
return S_OK;
}
阅读(5491) | 评论(0) | 转发(0) |