原帖地址
http://bbs.csdn.net/topics/390481350
解决办法
- procedure DisplayVideoInfo;
- var
- wmi, objs, obj : OleVariant;
- enum : IEnumVariant;
- value : Cardinal;
- begin
- try
- CoInitialize(nil);// 加上这两句
- wmi := CreateOleObject('WbemScripting.SWbemLocator');
- // ConnectServer无参表示连接本机
- objs := wmi.ConnectServer()
- .ExecQuery('SELECT * FROM Win32_VideoController');
- enum := IUnknown(objs._NewEnum) as IEnumVariant;
- enum.Reset;
- // 扫描每一块显卡
- while enum.Next(1, obj, value) = S_OK do
- begin
- szString.Add('名称 :' + obj.Name);
- szString.Add('制造商 :' + obj.AdapterCompatibility);
- szString.Add('芯片类型 :' + obj.VideoProcessor);
- szString.Add('DAC类型 :' + obj.AdapterDACType);
- szString.Add('显存 :' +
- VarToStr(Round(obj.AdapterRAM / 1024 / 1024)) + 'MB');
- szString.Add('颜色 :' + VarToStr(obj.CurrentBitsPerPixel) + '位');
- szString.Add(Format('屏幕分辨率是:%d * %d', [Screen.Width, Screen.Height]));
- end;
- finally
- CoUninitialize();//加上这两句
- end;
- end;