Fausto Lopez wrote:
> I'm getting the following error:
>
> 'strlen' : cannot convert parameter 1 from 'class CString' to 'const char
*'
Try
http://groups.google.com to find a group qualified to discuss CString.
This group can only reliably discuss platform neutral C++.
> when I try to compile the following code:
>
> HRESULT AnsiToUnicode(CString pszA, LPOLESTR* ppszW)
> {
Oookay. Nobody uses Hungarian Notation anymore. But "psz" means "pointer to
zero terminated string". This Department of Redundancy Department worked in
C using untypesafe conventions. CString is an object.
> ULONG cCharacters;
> DWORD dwError;
> // If input is null then just return the same.
> if (NULL == pszA)
This code treats pszA as a pointer, not an object. Try pszA.IsEmpty().
> {
> *ppszW = NULL;
> return NOERROR;
> }
> // Determine number of wide characters to be allocated for the
> // Unicode string.
> cCharacters = strlen(pszA)+1; <-------------------------
What's wrong with pszA.GetLength()?
I don't know what's wrong with pszA.operator LPCTSTR(), but you don't need
it. You could use a little more learning about both C++ and the MS library
supplying CString.
Also, MFC sucks, but you don't seem to be using all of it. Try WTL.
--
Phlip
http://industrialxp.org/community/bi...UserInterfaces