Bstr Type of COM DLL witten by C++ has problem.
Messages   Related Types
This message was discovered on microsoft.public.dotnet.framework.interop.

Post a new message to this list...

À̰­·æ
Hi

I can't send COM DLL's Bstr Type with c++

My Code is below(C#)
---------------------------------------------------------
//define Unmanaged Type
[MarshalAs(UnmanagedType.BStr)]
public String m_Bstr;

//an ellipsis

//Call

m_Bstr="test";

_Wrapper.VR_CreateTextObj(m_Bstr); <- this method receive BSTR type

------------------------------------------------------------

//a Result

m_Bstr="t"<--only 1st position of value sent.

If calling method with BSTR type parameter, value is wrong, only 1st
position of value sent.

-----------------------------------------------------------------------

VR_CreateTextObj method prototype..(made from c++)

------------------------

CreateTextObj(BSTR strText)

{

CString strLine;
strLine.Format("%s", strText);
AfxMessageBox(strLine);

}

advice me

thank you..

Reply to this message...
 
    
Mattias Sjögren
[Original message clipped]

BSTRs generally contain wide characters, so you should use %S rather
than %s as the format specifier type.

Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Reply to this message...
 
 
System.Runtime.InteropServices.UnmanagedType




Ad
MBR BootFX
Best-of-breed application framework for .NET projects, developed by Matthew Baxter-Reynolds and MBR IT
 
 Copyright © Matthew Baxter-Reynolds 2001-2008. '.NET 247 Software Development Services' is a trading style of MBR IT Solutions Ltd.
Contact Us - Terms of Use - Privacy Policy - www.dotnet247.com