HRESULT返回类型? [英] HRESULT Return Type?
本文介绍了HRESULT返回类型?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
STDMETHODIMP CDumpMessage :: DumpMessage(BSTR消息)
{
CString msg(Message);
OutputDebugString(msg);
}
这段代码给了错误..请帮助我..
STDMETHODIMP CDumpMessage::DumpMessage( BSTR Message )
{
CString msg(Message);
OutputDebugString(msg);
}
this piece of code is giving error..pls help me..
推荐答案
您不能在COM上传递CString作为参数,而是将其更改为BSTR ,使用CComBSTR在调用端包装CString,并使用CString在被调用端包装BSTR
变成
[ id( 1 ), helpstring( "Chat" )] HRESULT DumpMessage([in]BSTR Message );
来电者
you can''t pass a CString as a parameter across COM, change it to a BSTR, using CComBSTR to wrap the CString at the calling end, and CString to wrap the BSTR on the callee end
so it becomes
[ id( 1 ), helpstring( "Chat" )] HRESULT DumpMessage([in]BSTR Message );
caller
CString msg(_T("hello world"));
object->DumpMessage(CComBSTR(msg));
被呼叫者
callee
STDMETHOD(DumpMessage)(BSTR Message)
{
CString msg(Message);
OutputDebugString(msg);
}
此处: Wiki:HRESULT [
Here: Wiki: HRESULT[^]
It is a datatype and have a defined format. Not a normal string. CString is totally another datatype.
HRSULT-> [ ^ ]
HRESULT是一个32位无符号整数,指示消息的成功和失败.例如S_OK,E_NOINTERFACE.我们还可以创建自定义错误,也可以传递描述.
HRSULT ->[^]
The HRESULT is a 32-bit unsigned integer which indicate the success and failure of message. For example S_OK, E_NOINTERFACE. We can create our custom error also and pass the description also.
这篇关于HRESULT返回类型?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文