mnopix
asked on
CComBSTRr find replace
Hi,
I've a CComBSTR variable as below:
CComBSTR bstrUrl= L"https://www.experts-exchange.com/";
Here, how to change the "https" into "http" in the above string. No MFC involved so CString cannot be used.
Thanks in advance
I've a CComBSTR variable as below:
CComBSTR bstrUrl= L"https://www.experts-exchange.com/";
Here, how to change the "https" into "http" in the above string. No MFC involved so CString cannot be used.
Thanks in advance
>> and an OLECHAR* is typdef'ed as a WCHAR
should be
and an OLECHAR is typdef'ed as a WCHAR (no pointer type)
should be
and an OLECHAR is typdef'ed as a WCHAR (no pointer type)
ASKER
I'm getting following compile errors:
abc.cpp(1716) : error C2653: 'string' : is not a class or namespace name
abc.cpp(1716) : errorC2065: 'npos' : undeclared identifier
Am I missing some include files?
abc.cpp(1716) : error C2653: 'string' : is not a class or namespace name
abc.cpp(1716) : errorC2065: 'npos' : undeclared identifier
Am I missing some include files?
ASKER
About the Build Environment:
Windows Server 2003
Platform Builder for MS Windows CE 5.0
Windows Server 2003
Platform Builder for MS Windows CE 5.0
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you very much for your effort. As our project approch was changed we decided keep the 'https' as its. So I've not verified the last comment.
No problem, you will find it works :)
Internally, the constructor has the code
m_str = ::SysAllocString(pSrc);
where pSrc is the string you passed in. The destructor, I would assume, calls SysFreeString, passing m_str. (I cannot prove this since I cannot step into the destructor for some reason).
Anyway, that being said, you can see that you can use standard wide string handling API functions to manipulate the member m_str, or, as I did, std::wstring, which is a lot easier. The only thing you need to watch out for is that you take care of the memory occupied by m_str, if, for example, you increase the length of it. You could write a wrapper function to do a replace operation, something like the code below.
HTH
Open in new window