#include <string.h>
#include <Windows.h>
#include <stdio.h>
#include <stdlib.h>
int main(void)
{
LPSTR lpstr="测试123";
LPWSTR lpwstr;
DWORD dwNum = MultiByteToWideChar (CP_ACP, 0, lpstr, -1, NULL, 0);
lpwstr=(LPWSTR)calloc(dwNum,sizeof(WCHAR));//
MultiByteToWideChar (CP_ACP, 0, lpstr, -1, lpwstr, dwNum);
MessageBoxA(NULL,lpstr,"ANSI码",MB_OK);
MessageBoxW(NULL,lpwstr,L"UNCODE码",MB_OK);
system("PAUSE");
return 0;
}
鼓捣了一天,终于弄出来了,注意黄字函数最后一个参数要利用第一次该函数返回的长度,还要动态分配内存