万分火急,这是怎么回事啊,unresolved external symbol _IID_IDirectDraw7
taxi 2004-12-18 09:37:05 做一人极简单的使用DirectDraw的程序,出现如下错误:
Linking...
Startup.obj : error LNK2001: unresolved external symbol _IID_IDirectDraw7
Debug/DDrawDemo.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.
这是怎么回事,我已经将ddraw.lib加到工程的link中了,且在VC中已经将DirectX的lib和include目录加进去了。
我编译windows游戏编译大师技巧中的源代码却不会有这种错误。
以下是我的源代码,就一个文件:
#include <windows.h>
#include <ddraw.h>
const int SCREEN_WIDTH = 640;
const int SCREEN_HEIGHT = 480;
const int COLORS_PER_PIXEL = 8;
const char* CLASS_NAME= "DirectDraw";
const char* WINDOW_NAME = "Direct Draw Demo";
HWND gMainFormHandle;
LPDIRECTDRAW7 gDirectDraw;
LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
int InitDDraw();
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR lpCmdLine, int nCmdShow)
{
WNDCLASSEX wndCls;
MSG msg;
wndCls.cbSize = sizeof(WNDCLASSEX);
wndCls.cbClsExtra = 0;
wndCls.cbWndExtra = 0;
wndCls.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);
wndCls.hCursor = LoadCursor(hInstance, IDC_ARROW);
wndCls.hIcon = LoadIcon(hInstance, IDI_APPLICATION);
wndCls.hIconSm = LoadIcon(hInstance, IDI_APPLICATION);
wndCls.hInstance = hInstance;
wndCls.lpfnWndProc = WndProc;
wndCls.lpszClassName = CLASS_NAME;
wndCls.lpszMenuName = NULL;
wndCls.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC;
if (!RegisterClassEx(&wndCls))
return 0;
gMainFormHandle = CreateWindowEx(0, CLASS_NAME, WINDOW_NAME,
WS_OVERLAPPEDWINDOW | WS_VISIBLE, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT,
0, 0, hInstance, NULL);
if (!gMainFormHandle)
return 0;
if (!InitDDraw())
return 0;
ShowWindow(gMainFormHandle, nCmdShow);
UpdateWindow(gMainFormHandle);
while (GetMessage(&msg, 0, 0, 0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return 1;
}
LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch (msg)
{
case WM_DESTROY: PostQuitMessage(0); return 0;
default:
return DefWindowProc(hWnd, msg, wParam, lParam);
}
}
int InitDDraw()
{
if (DirectDrawCreateEx(NULL, (void **)&gDirectDraw, IID_IDirectDraw7, NULL) != S_OK)
{
return 0;
}
return 1;
}