问题描述
我使用一段使用直接绘图的遗留代码,而我处于相当尴尬的境地.
不久前,我已经更新了系统,不得不适应新的情况(加载ddraw.dll),并且一切正常.
今天,我探索了另一个旧的解决方案,该解决方案共享已更改的文件,但是我遇到了上述链接错误.我检查并比较了项目属性,发现它们很好缝.
这是用于DirectX初始化的代码,麻烦的"代码为粗体.
I work with piece of legacy code which uses direct draw and I''m in rather embarrassing situation.
Not long ago I''ve updated my system and had to adapt to the new situation (loading ddraw.dll) and everything worked fine.
Today I explored another legacy solution which shares files I''ve changed, but I''m stuck with above mentioned linking error. I''ve checked and compared project properties and they seam fine.
This is code for directX initialization, "troublesome" code is bold.
typedef int (__stdcall *DirectDrawCreateFunc)(GUID FAR* a ,LPDIRECTDRAW FAR* b, IUnknown FAR* c);
/* init_directx:
* Low-level DirectDraw initialization routine.
*/
int CDCUtils::init_directx(HWND allegro_wnd)
{
LPDIRECTDRAW directdraw1;
HRESULT hr;
LPVOID temp;
HINSTANCE ddraw = LoadLibrary("%WINDIR%\system32\ddraw.dll");
if(ddraw== NULL)
{
return -1;
}
_ddrawLib =ddraw;
DirectDrawCreateFunc ddFunc = (DirectDrawCreateFunc)GetProcAddress(ddraw,"DirectDrawCreate");
if(ddFunc)
{
/* first we have to set up the DirectDraw1 interface... */
hr = ddFunc(NULL, &directdraw1, NULL);
if (FAILED(hr))
return -1;
}
///* first we have to set up the DirectDraw1 interface... */
//hr = DirectDrawCreate(NULL, &directdraw1, NULL);
//if (FAILED(hr))
// return -1;
//...then query the DirectDraw2 interface
//This is the only place where IID_IDirectDraw2 is mentioned in entire solution
hr=directdraw1->QueryInterface(IID_IDirectDraw2, &temp);
if (FAILED(hr))
return -1;
_directdraw = (LPDIRECTDRAW2)temp;
directdraw1->Release();
/* set the default cooperation level */
hr = IDirectDraw2_SetCooperativeLevel(_directdraw, allegro_wnd, DDSCL_NORMAL);
if (FAILED(hr))
return -1;
/* get capabilities */
_ddcaps.dwSize = sizeof(_ddcaps);
hr = IDirectDraw2_GetCaps(_directdraw, &_ddcaps, NULL);
if (FAILED(hr)) {
TRACE("Can''t get driver caps\n");
return -1;
}
_dxHwnd=allegro_wnd;
return 0;
}
有什么想法吗?
为什么它只能在一种解决方案中起作用而不能在这种解决方案中起作用?
哦,链接器,我讨厌您.
Any ideas?
Why it works in one solution and not in this one?
Oh linker I loathe thee.
推荐答案
这篇关于错误LNK2001:无法解析的外部符号_IID_IDirectDraw2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!