错误 LNK2001:未解析的外部符号_IID_IDirectDraw2

error LNK2001: unresolved external symbol _IID_IDirectDraw2

本文关键字:符号 外部 IID IDirectDraw2 LNK2001 错误      更新时间:2023-10-16

我使用一段使用直接绘制的遗留代码,我处于相当尴尬的境地。不久前,我已经更新了我的系统,不得不适应新情况(加载 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%system32ddraw.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 capsn");
          return -1;
       }
       _dxHwnd=allegro_wnd;
      return 0;
    } 

有什么想法吗?为什么它适用于一种解决方案而不是此解决方案?哦,林克,我讨厌你。

是否向项目的链接器输入添加了dxguid.lib

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

相关文章: