473,473 Members | 1,975 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

CString conversion problem while compling with /clr switch

1 New Member
Hi All,

I am trying to compile an existing C++ unamanaged application with the /clr switch in VS.Net 2003, as I need to use managed extensions in the code.

In a cpp file I have the following code :

CString strRet;
COleVariant var = m_pRSTFormList->GetFieldValue("FormName");
if(var.vt == VT_BSTR)
strRet = var.pbVal;


However the compiler gives the following error -

error C2664: 'PtrToStringChars' : cannot convert parameter 1 from 'BYTE *' to 'const System::String __gc *'
Conversion from 'void*' to pointer to non-'void' requires an explicit cast
BrowserDatabase.cpp(223) : see reference to function template instantiation 'ATL::CStringT<BaseType,StringTraits>::CStringT<BY TE>(SystemString *)' being compiled
with
[
BaseType=char,
StringTraits=StrTraitMFC_DLL<char>,
SystemString=BYTE
]


I got to know that CString has a constructor that takes System::String * parameter. However in this case I have a Byte *. Any form of casting like
strRet = (Cstring) var.pbVal;
strRet = (System::String *) var.pbVal or even a static_cast does not seem to work.

Your help would be highly appreciated.
Thanks in advance,
Niranjan.
Aug 14 '06 #1
0 2232

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: Markus Hämmerli | last post by:
I ' ll tra to convert a Cstring to char* without success. I working in a Unicode enabled environment this is working in Unicode CString source = _T("TestString"); TCHAR *szSource =...
0
by: Chris | last post by:
Hi all, Just converted our 95 project workspace file from VC++ 6.0 to .NET, and things have gone...um...pretty well. Down to the last of the suffering - our main server application is doing...
3
by: Terry chan | last post by:
Hi, How to convert String object to MFC CString? and from CString to String? Thanks! chan
9
by: Fausto Lopez | last post by:
I'm getting the following error: 'strlen' : cannot convert parameter 1 from 'class CString' to 'const char *' when I try to compile the following code: HRESULT AnsiToUnicode(CString pszA,...
5
by: Paul | last post by:
Hi, Any one knows how to convert CString to LPCWSTR? Please advice, thanks! -P
5
by: Neo | last post by:
how convert CString to char *? regards, Mohammad Omer Nasir
0
by: uwe.braunholz | last post by:
hi, while experimenting with the inputmethods for different languages I noticed the conversion mode with chinese IME. The following occures: I set the InputLanguage to chinese with the...
16
by: Norman Diamond | last post by:
In an antique obsolete version of MFC, a CString expression could be subscripted in order to retrieve one element. Visual Studio 2005 defines CSimpleStringT::operator. At first glance it looks...
1
by: YouPoP | last post by:
For a reason i don't know, if i convert a float to a cstring, it does not convert to an exact value for all values except round numbers or 1/2 numbers; the following code (used to convert and...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.