程序出现了中断,不知道如何查询错误所在,
用win32写程序是::
#include<windowS.h>
LRESULT CALLBACK WndProc(HWND,UINT,WPARAM,LPARAM);
int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInst,LPSTR lpszCmdline,int nCmdShow)
{
HWND hwnd;
MSG Msg;
WNDCLASS wndclass;
static TCHAR lpszClassName[]=TEXT("窗口");
wndclass.style=0;
wndclass.cbClsExtra=0;
wndclass.cbWndExtra=0;
wndclass.hInstance=hInstance;
wndclass.hIcon=LoadIcon(NULL,IDI_APPLICATION);
wndclass.hCursor=LoadCursor(NULL,IDC_ARROW);
wndclass.hbrBackground=(HBRUSH)GetStockObject(WHITE_BRUSH);
wndclass.lpszMenuName=NULL;
wndclass.lpszClassName=lpszClassName;
if(!RegisterClass(&wndclass))
{
MessageBox(NULL,TEXT("THIS PROGRAME REQUIRE WINDOWS NT"),lpszClassName,MB_ICONERROR);
return 0;
}
hwnd=CreateWindow(lpszClassName,
TEXT("My_windows"),
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
NULL,
NULL,
hInstance,
NULL);
ShowWindow(hwnd,nCmdShow);
UpdateWindow(hwnd);
while(GetMessage(&Msg,NULL,0,0))
{TranslateMessage(&Msg);
DispatchMessage(&Msg);
}
return Msg.wParam;
}
LRESULT CALLBACK WndProc(HWND hwnd, UINT message,WPARAM wParam,LPARAM lParam)
{
HDC hdc;
PAINTSTRUCT ps;
RECT rect;
switch(message)
{
case WM_CREATE:
//PlaySound(TEXT("hellowin.wav"),NULL,SND_FILENAME|SND_ASYNC);
return 0;
case WM_PAINT:
hdc=BeginPaint(hwnd,&ps);
GetClientRect(hwnd,&rect);
DrawText(hdc,TEXT("hello,windows7"),-1,&rect,DT_SINGLELINE|DT_CENTER|DT_VCENTER);
EndPaint(hwnd,&ps);
return 0;
case WM_DESTROY:
PostQuitMessage(0);
return 0; }
return DefWindowProc(hwnd,message,wParam,lParam) ;
}
提示错误:
hello.exe 中的 0x00000000 处未处理的异常: 0xC0000005: 读取位置 0x00000000 时发生访问冲突
- hInstance 0x00bc0000 {unused=9460301 } HINSTANCE__ *
unused 9460301 int
- hwnd 0xcccccccc {unused=??? } HWND__ *
unused CXX0030: 错误: 无法计算表达式的值
- lpszClassName 0x00bd7000 "窗口" wchar_t [3]
[0] 31383 L'窗' wchar_t
[1] 21475 L'口' wchar_t
[2] 0 wchar_t
用win32写程序是::
#include<windowS.h>
LRESULT CALLBACK WndProc(HWND,UINT,WPARAM,LPARAM);
int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInst,LPSTR lpszCmdline,int nCmdShow)
{
HWND hwnd;
MSG Msg;
WNDCLASS wndclass;
static TCHAR lpszClassName[]=TEXT("窗口");
wndclass.style=0;
wndclass.cbClsExtra=0;
wndclass.cbWndExtra=0;
wndclass.hInstance=hInstance;
wndclass.hIcon=LoadIcon(NULL,IDI_APPLICATION);
wndclass.hCursor=LoadCursor(NULL,IDC_ARROW);
wndclass.hbrBackground=(HBRUSH)GetStockObject(WHITE_BRUSH);
wndclass.lpszMenuName=NULL;
wndclass.lpszClassName=lpszClassName;
if(!RegisterClass(&wndclass))
{
MessageBox(NULL,TEXT("THIS PROGRAME REQUIRE WINDOWS NT"),lpszClassName,MB_ICONERROR);
return 0;
}
hwnd=CreateWindow(lpszClassName,
TEXT("My_windows"),
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
NULL,
NULL,
hInstance,
NULL);
ShowWindow(hwnd,nCmdShow);
UpdateWindow(hwnd);
while(GetMessage(&Msg,NULL,0,0))
{TranslateMessage(&Msg);
DispatchMessage(&Msg);
}
return Msg.wParam;
}
LRESULT CALLBACK WndProc(HWND hwnd, UINT message,WPARAM wParam,LPARAM lParam)
{
HDC hdc;
PAINTSTRUCT ps;
RECT rect;
switch(message)
{
case WM_CREATE:
//PlaySound(TEXT("hellowin.wav"),NULL,SND_FILENAME|SND_ASYNC);
return 0;
case WM_PAINT:
hdc=BeginPaint(hwnd,&ps);
GetClientRect(hwnd,&rect);
DrawText(hdc,TEXT("hello,windows7"),-1,&rect,DT_SINGLELINE|DT_CENTER|DT_VCENTER);
EndPaint(hwnd,&ps);
return 0;
case WM_DESTROY:
PostQuitMessage(0);
return 0; }
return DefWindowProc(hwnd,message,wParam,lParam) ;
}
提示错误:
hello.exe 中的 0x00000000 处未处理的异常: 0xC0000005: 读取位置 0x00000000 时发生访问冲突
- hInstance 0x00bc0000 {unused=9460301 } HINSTANCE__ *
unused 9460301 int
- hwnd 0xcccccccc {unused=??? } HWND__ *
unused CXX0030: 错误: 无法计算表达式的值
- lpszClassName 0x00bd7000 "窗口" wchar_t [3]
[0] 31383 L'窗' wchar_t
[1] 21475 L'口' wchar_t
[2] 0 wchar_t
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货