下面的程序在 VC6 通过,在 VS2008 不能,错误信息都是“不能将参数……从
const char[]转换为 LPCWSTR”
#include<windows.h>
#include<stdio.h>
int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR
lpCmdLine,int nCmdShow)
{
LRESULT CALLBACK WndSunProc(HWND hwnd,UINT uMsg,WPARAM
wParam,LPARAM lParam);
WNDCLASS wndclass;
wndclass.style=CS_HREDRAW|CS_NOCLOSE;
wndclass.lpfnWndProc=WndSunProc;
wndclass.cbClsExtra=0;
wndclass.cbWndExtra=0;
wndclass.hInstance=hInstance;
wndclass.hIcon=LoadIcon(NULL,IDI_ERROR);
wndclass.hCursor=LoadCursor(NULL,IDC_ARROW);
wndclass.hbrBackground=(HBRUSH)GetStockObject(WHITE_BRUSH);
wndclass.lpszMenuName=NULL;
wndclass.lpszClassName="fanqie";
RegisterClass(&wndclass);
HWND hwnd;
hwnd=CreateWindow("fanqie","我的第一个窗
口",WS_OVERLAPPEDWINDOW,50,50,300,200,NULL,NULL,hInstance,NULL);
ShowWindow(hwnd,SW_SHOWNORMAL);
UpdateWindow(hwnd);
MSG msg;
while(GetMessage(&msg,hwnd,0,0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return 0;
}
LRESULT CALLBACK WndSunProc(HWND hwnd,UINT uMsg,WPARAM
wParam,LPARAM lParam)
{
switch(uMsg)
{
case WM_CHAR:
char szChar[20];
sprintf(szChar,"char is %c",wParam);
MessageBox(hwnd,szChar,"字符",0);
break;
评论5