Click here to Skip to main content
15,905,612 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
STDMETHODIMP CDumpMessage::DumpMessage( BSTR Message )
{
CString msg(Message);
OutputDebugString(msg);

}

this piece of code is giving error..pls help me..
Posted
Updated 2-Jun-11 22:07pm
v3

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);
}
 
Share this answer
 
Comments
Sona from kerala 3-Jun-11 1:55am    
Thanks for your help..it realy worked.
Here: Wiki: HRESULT[^]

It is a datatype and have a defined format. Not a normal string. CString is totally another datatype.
 
Share this answer
 
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.
 
Share this answer
 
better u post it as a separate qstn instead of editing. it is different from previuos qstn. also please tell what is the error?
 
Share this answer
 
Please explain your question and give some more lines of coding......
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900