-
June 9th, 2001, 03:30 AM
#1
Convert char * to OLECHAR *
Hi all.
How can i convert char * variable to OLECHAR * variable ???
My month article: Game programming by DirectX by Lan Mader.
Please visit in: www.geocities.com/hadi_rezaie/index.html
Hadi Rezaie
-
June 9th, 2001, 05:12 AM
#2
Re: Convert char * to OLECHAR *
Hi Hadi Rezaie,
you can use
size_t mbstowcs( wchar_t *wcstr, const char *mbstr, size_t count );
because OLECHAR is wchar_t.
Bye
Peter
-
June 9th, 2001, 05:50 AM
#3
Re: Convert char * to OLECHAR *
hmmm, i read MSDN, yeah OLECHAR = wchar_t ...
But i didn't understand how can i convert !!!
Can you write any code ?
My month article: Game programming by DirectX by Lan Mader.
Please visit in: www.geocities.com/hadi_rezaie/index.html
Hadi Rezaie
-
June 9th, 2001, 10:54 AM
#4
Re: Convert char * to OLECHAR *
See http://www.codeguru.com/cgi-bin/bbs/...age=&view=&sb=
In your case:
#include <atlconv.h>
...
USES_CONVERSION;
LPCOLESTR poleString = OLESTR("Whatever");
const char *pString = OLE2CA(poleString); // Macro converts "OLECHAR" string to constant "char" string
-
June 9th, 2001, 11:39 AM
#5
Re: Convert char * to OLECHAR *
Hi,
hope this short example helps.
Bye
Peter
...
#include <windows.h>
#include <objbase.h>
...
void MyMessageBox(char *sText)
{
// reserve memory for the OLECHAR-string
OLECHAR *sOleText=new OLECHAR[strlen(sText)+1];
// convert the char-string to OLECHAR-string
mbstowcs(sOleText,sText,strlen(sText)+1); // +1 means: don't forget the terminating null character
// show content of OLECHAR-string by calling the wide-character-version of MessageBox
MessageBoxW(GetDesktopWindow(),sOleText,OLESTR("Caption"),MB_OK);
// free memory of the OLECHAR-string
delete sOleText;
}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|