3

我使用了一段使用直接绘制的遗留代码,我处于相当尴尬的境地。不久前,我更新了系统,不得不适应新情况(加载 ddraw.dll),一切正常。今天我探索了另一个遗留解决方案,它也使用了我已经更改的类(文件),但我遇到了上面提到的链接错误。我检查并比较了项目属性,它们接缝很好。

这是directX初始化的代码,“麻烦”的代码是粗体的。

 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;
    } 

有任何想法吗?为什么它适用于一种解决方案而不适用于这个解决方案?哦链接器我讨厌你。

4

2 回答 2

7

您是否添加dxguid.lib到项目的链接器输入

于 2011-05-11T15:08:20.200 回答
0

确保在项目中添加 Dxguid.lib。

于 2011-05-11T15:09:04.970 回答