|
|
该程序工程内仅有一个qx1.cpp文件,程序功能也仅仅是创建一个全黑色的屏幕。试着编译,编译通过,但按ctrl+F5运行时弹出一对画框(对话框内容如下:
Microsoft Visual c++ Debug Library
Debug Error!
Program :\游戏编程\qx1_\Debug\qx_1.exe
Moudle:
File:i386\chkesp.c
Line:42
The value of ESP was not properly saved across a function call. This is usually a result of calling a function declared with one calling convention with a function pointer declared with a different calling
convention.
(press Retry to debug the application)
终止 重试 忽略 ) ,
程序无法运行。我用的是directx 8.1 sdk,include等都已经加在了vc++6.0上,并位于第一位置,dxguid.lib,ddraw.lib也已设置,我已经弄了半个月,dx8.1sdk与dx8.1也重装了许多遍,也不知道问题出在哪里,大家帮帮我啊!
下边是源代码:
qx1.cpp文件
#include <windows.h> // include important windows stuff
#include <ddraw.h>
HWND main_window_handle;
HINSTANCE main_instance;
LPDIRECTDRAW7 lpDDraw7=NULL;
LRESULT CALLBACK WndProc(HWND hwnd,UINT message, WPARAM wParam,
LPARAM lParam);
int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpCmdLine,int nCmdShow)
{
LPDIRECTDRAW lpDDraw_temp=NULL;
char lpszClassName[]="nihao",lpszTitle[]="边缘战争";
HWND hwnd;
MSG msg;
WNDCLASS wndclass;
wndclass.style = 0;
wndclass.lpfnWndProc = WndProc;
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;
main_instance=hInstance;
if(!RegisterClass(&wndclass))
{
return 0;
}
hwnd = CreateWindow(lpszClassName,
lpszTitle,
WS_OVERLAPPEDWINDOW,
0,
0,
320,
240,
NULL,
NULL,
hInstance,
NULL );
ShowWindow(hwnd,nCmdShow);
UpdateWindow(hwnd);
main_window_handle=hwnd;
if (FAILED(DirectDrawCreate(NULL, &lpDDraw_temp, NULL)))
{
MessageBox(NULL,TEXT("Direct Draw Create error!"),
TEXT("Wrong!"),MB_OK);return 0;
}
if (FAILED(lpDDraw_temp->QueryInterface(IID_IDirectDraw,
(LPVOID *)&lpDDraw7)))
{
MessageBox(NULL,TEXT("DirectDraw QueryInterface error!"),
TEXT("Wrong!"),MB_OK);
return(0);
}
if (FAILED(lpDDraw7->SetCooperativeLevel(main_window_handle,
DDSCL_FULLSCREEN | DDSCL_ALLOWMODEX |
DDSCL_EXCLUSIVE | DDSCL_ALLOWREBOOT)))
{
MessageBox(NULL,TEXT("DirectDraw SetCooperativeLevel error!"),
TEXT("Wrong!"),MB_OK);return 0;
}
if (FAILED(lpDDraw7->SetDisplayMode(800, 600, 16,0,0)))
{
MessageBox(NULL,TEXT("DirectDraw SetDisplayMode error!"),
TEXT("Wrong!"),MB_OK);return 0;
}
while(GetMessage(&msg,NULL,0,0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return msg.wParam;
}
LRESULT CALLBACK WndProc(HWND hwnd,UINT message, WPARAM wParam,
LPARAM lParam)
{
switch(message)
{
case VK_ESCAPE:
;
default:
return DefWindowProc(hwnd,message,wParam,lParam);
}return 0;}
一个偶然操作:最下边窗口显示:
Loaded symbols for 'D:\pc游戏编程\YOUXI\q_x\Debug\q_x.exe'
Loaded 'C:\WINDOWS\system32\ntdll.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\kernel32.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\ddraw.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\msvcrt.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\user32.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\gdi32.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\dciman32.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\advapi32.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\rpcrt4.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\imm32.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\lpk.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\usp10.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\uxtheme.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\msctf.dll', no matching symbolic information found.
Loaded 'D:\HEROSOFT\HeroV8\VCvtShell.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\shell32.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\shlwapi.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\WinSxS\x86_Microsoft.Windows.Common-Controls_6595b64144ccf1df_6.0.2600.2180_x-ww_a84f1ff9\comctl32.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\comctl32.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\msctfime.ime', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\ole32.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\version.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\apphelp.dll', no matching symbolic information found.
The thread 0x148 has exited with code 0 (0x0).
The thread 0x1E4 has exited with code -2147483645 (0x80000003).
The program 'D:\pc游戏编程\YOUXI\q_x\Debug\q_x.exe' has exited with code -2147483645 (0x80000003
|
|