如题

解决方案 »

  1.   

    #include <ddraw.h>#pragma comment(lib, "guids.lib") LPDIRECTDRAW2 lpdd;
    HRESULT ddrval; ddrval = CoCreateInstance(CLSID_DirectDraw,
        NULL, CLSCTX_ALL, IID_IDirectDraw2, (void**)&lpdd);
    if(!FAILED(ddrval))
    {
    ddrval = IDirectDraw2_Initialize(lpdd, NULL);
    } DDCAPS ddcaps; ddcaps.dwSize = sizeof DDCAPS;
    lpdd->GetCaps(&ddcaps, NULL); lpdd->Release(); DWORD dwMem = ddcaps.dwVidMemTotal; CoUninitialize();
      

  2.   

    谢谢!
    不过为什么得到是32397824转为M是30.89M,而不是32M?
      

  3.   

    还有,显卡DAC的类型怎么得到?
      

  4.   

    The IDirectDraw2::GetCaps method fills in the capabilities of the device driver for the hardware and the hardware-emulation layer (HEL).HRESULT GetCaps(
      LPDDCAPS lpDDDriverCaps,  
      LPDDCAPS lpDDHELCaps  
    );
     
    Parameters
    lpDDDriverCaps 
    Address of a DDCAPS structure that will be filled with the capabilities of the hardware, as reported by the device driver. Set this parameter to NULL if device driver capabilities are not to be retrieved. 
    lpDDHELCaps 
    Address of a DDCAPS structure that will be filled with the capabilities of the HEL. Set this parameter to NULL if HEL capabilities are not to be retrieved.
      

  5.   

    如果你的硬件支持的话可以调用
    lpdd->GetCaps(NULL,&ddcaps);来获取,第一种方式得到的会有误差以下是DDCAPS的定义,找你感兴趣的信息typedef struct _DDCAPS { 
        DWORD    dwSize; 
        DWORD    dwCaps;                  // driver-specific caps
        DWORD    dwCaps2;                 // more driver-specific caps
        DWORD    dwCKeyCaps;              // color key caps
        DWORD    dwFXCaps;                // stretching and effects caps
        DWORD    dwFXAlphaCaps;           // alpha caps
        DWORD    dwPalCaps;               // palette caps
        DWORD    dwSVCaps;                // stereo vision caps
        DWORD    dwAlphaBltConstBitDepths;       // alpha bit-depth members
        DWORD    dwAlphaBltPixelBitDepths;       //  .
        DWORD    dwAlphaBltSurfaceBitDepths;     //  .
        DWORD    dwAlphaOverlayConstBitDepths;   //  .
        DWORD    dwAlphaOverlayPixelBitDepths;   //  .
        DWORD    dwAlphaOverlaySurfaceBitDepths; //  .
        DWORD    dwZBufferBitDepths;      // Z-buffer bit depth
        DWORD    dwVidMemTotal;           // total video memory
        DWORD    dwVidMemFree;            // total free video memory
        DWORD    dwMaxVisibleOverlays;    // maximum visible overlays
        DWORD    dwCurrVisibleOverlays;   // overlays currently visible
        DWORD    dwNumFourCCCodes;        // number of supported FOURCC codes
        DWORD    dwAlignBoundarySrc;      // overlay alignment restrictions
        DWORD    dwAlignSizeSrc;          //  .
        DWORD    dwAlignBoundaryDest;     //  .
        DWORD    dwAlignSizeDest;         //  .
        DWORD    dwAlignStrideAlign;      // stride alignment
        DWORD    dwRops[DD_ROP_SPACE];    // supported raster ops
        DDSCAPS  ddsCaps;                 // general surface caps
        DWORD    dwMinOverlayStretch;     // overlay stretch factors
        DWORD    dwMaxOverlayStretch;     //  .
        DWORD    dwMinLiveVideoStretch;   // obsolete
        DWORD    dwMaxLiveVideoStretch;   //  .
        DWORD    dwMinHwCodecStretch;     //  .
        DWORD    dwMaxHwCodecStretch;     //  .
        DWORD    dwReserved1;             // reserved
        DWORD    dwReserved2;             //  .
        DWORD    dwReserved3;             //  .
        DWORD    dwSVBCaps;               // system-to-video blit related caps
        DWORD    dwSVBCKeyCaps;           //  .
        DWORD    dwSVBFXCaps;             //  .
        DWORD    dwSVBRops[DD_ROP_SPACE]; //  .
        DWORD    dwVSBCaps;               // video-to-system blit related caps
        DWORD    dwVSBCKeyCaps;           //  .
        DWORD    dwVSBFXCaps;             //  .
        DWORD    dwVSBRops[DD_ROP_SPACE]; //  .
        DWORD    dwSSBCaps;               // system-to-system blit related caps
        DWORD    dwSSBCKeyCaps;           //  .
        DWORD    dwSSBCFXCaps;            //  .
        DWORD    dwSSBRops[DD_ROP_SPACE]; //  .
        DWORD    dwMaxVideoPorts;         // maximum number of live video ports
        DWORD    dwCurrVideoPorts;        // current number of live video ports
        DWORD    dwSVBCaps2;              // additional system-to-video blit caps
        DWORD    dwNLVBCaps;              // nonlocal-to-local video memory blit caps
        DWORD    dwNLVBCaps2;             //  .
        DWORD    dwNLVBCKeyCaps;          //  .
        DWORD    dwNLVBFXCaps;            //  .
        DWORD    dwNLVBRops[DD_ROP_SPACE];//  .
        DWORD    dwReserved4;             // reserved
        DWORD    dwReserved5;             //  .
        DWORD    dwReserved6;             //  .
    } DDCAPS,FAR* LPDDCAPS;