请教 关于LPCWSTR类型的赋值问题
一个windows的小窗口程序,在VS2010上面运行的,编译没通过, 都是提示LPCWSTR类型与char [8] 或者 const char [8]类型不兼容,无法转化。我把那些字符串强制转化为LPCWSTR类型,虽然可以运行了,但是都是乱码...
我看视频教程里是在VC++ 6.0上面运行的,都没问题....
这个要怎么办啊?
代码:
#include<windows.h>
#include<stdio.h>
LRESULT CALLBACK WinLeeProc(
__in HWND hwnd,
__in UINT uMsg,
__in WPARAM wParam,
__in LPARAM lParam
);
int WINAPI WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
WNDCLASS wincls;
wincls.cbClsExtra = 0;
wincls.cbWndExtra = 0;
wincls.hbrBackground = (HBRUSH)GetStockObject(DKGRAY_BRUSH);
wincls.hCursor = LoadCursor(NULL,IDC_CROSS);
wincls.hIcon = LoadIcon(NULL,IDI_ERROR);
wincls.hInstance = hInstance;
wincls.lpfnWndProc = WinLeeProc;
wincls.lpszClassName = "Lee2012"; //这里
wincls.lpszMenuName = NULL;
wincls.style = CS_HREDRAW | CS_VREDRAW;
RegisterClass(&wincls);
HWND hwnd;
hwnd = CreateWindow("Lee2012","TestApplication 1",WS_OVERLAPPEDWINDOW,0,0,CW_USEDEFAULT,CW_USEDEFAULT,NULL,NULL,hInstance,NULL); //这里
ShowWindow(hwnd,SW_SHOWMAXIMIZED);
UpdateWindow(hwnd);
MSG msg;
while(GetMessage(&msg,NULL,0,0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return 0;
}
LRESULT CALLBACK WinLeeProc(
__in HWND hwnd,
__in UINT uMsg,
__in WPARAM wParam,
__in LPARAM lParam
)
{
switch(uMsg)
{
case WM_PAINT:
HDC hdc1;
PAINTSTRUCT ps;
hdc1 = BeginPaint(hwnd,&ps);
TextOut(hdc1,0,0,"培训",strlen("培训")); //这里.. 还有好几个地方....
EndPaint(hwnd,&ps);
break;
case WM_CHAR:
char szChar[20];
sprintf(szChar,"char is %d",wParam);
MessageBox(hwnd,szChar,"linan01",0);
break;
case WM_LBUTTONDOWN:
MessageBox(hwnd,"Left clicked","linan02",0);
HDC hdc2;
hdc2=GetDC(hwnd);
TextOut(hdc2,0,50,"123456",strlen("123456"));
ReleaseDC(hwnd,hdc2);
break;
case WM_CLOSE:
if(IDYES==MessageBox(hwnd,"True Out?","linan03",MB_YESNO))
{
DestroyWindow(hwnd);
}
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hwnd,uMsg,wParam,lParam);
}
return 0;
}