得到显存的大小

#include
#pragma comment(lib, "guids.lib")

 LPDIRECTDRAW2 lpdd;
 HRESULT ddrval;
 
 CoInitialize(NULL); 
 
 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;

 int iMem = dwMem/1024/1024;

 CString strMem;
 strMem.Format(_T("display memory is %d MB"),iMem);

 AfxMessageBox(strMem);
 
 CoUninitialize();

你可能感兴趣的:(VC/MFC)