阅读:2103回复:5
请问各位前辈门PCWSTR类型怎么转换成char*类型呢?
请问各位前辈门PCWSTR类型怎么转换成char*类型呢谢谢?
|
|
沙发#
发布于:2004-11-05 16:31
使用这个函数WideCharToMultiByte
|
|
|
板凳#
发布于:2004-11-05 16:34
函数原型
int WideCharToMultiByte( UINT CodePage, DWORD dwFlags, LPCWSTR lpWideCharStr, int cchWideChar, LPSTR lpMultiByteStr, int cbMultiByte, LPCSTR lpDefaultChar, LPBOOL lpUsedDefaultChar ); |
|
|
地板#
发布于:2004-11-05 16:41
例如:
LPWSTR lpwstring; LPSTR lpstring=NULL; int nLen = WideCharToMultiByte(CP_ACP, 0,lpwstring, -1, NULL, 0,NULL,NULL); if(GetLastError()==ERROR_INSUFFICIENT_BUFFER) { lpstring = new char[nLen]; WideCharToMultiByte(CP_ACP, 0,lpwstring, -1, lpstring, nLen,NULL,NULL); } delete []lpstring; |
|
|
地下室#
发布于:2004-11-05 17:09
谢谢你了,我先看看。
|
|
5楼#
发布于:2004-11-05 20:48
LPWSTR lpwstring;
LPSTR lpstring=NULL; _asm { mov eax,lpwstring mov lpstring,eax } 嘿嘿...... |
|
|