View Single Post
  #2  
Old 30-05-2020, 17:23
Razor12911's Avatar
Razor12911 Razor12911 is offline
Noob
 
Join Date: Jul 2012
Location: South Africa
Posts: 3,749
Thanks: 2,170
Thanked 11,206 Times in 2,307 Posts
Razor12911 is on a distinguished road
Quote:
Originally Posted by Cesar82 View Post
This subject is also of interest, so I ask questions.
This GUID is variable from system to system.
Here there are 6 GUIDs with DedicatedVideoMemory values, one of which is from the ON-BOARD video card.
But the GUID bears no resemblance to those of your images.

How to identify the correct GUID to obtain the video value?
I decided to check where these values really came from
SOFTWARE\Microsoft\DirectX\ - DirectX is a clue so one has to go on msdn
which is here
https://docs.microsoft.com/en-us/win...i_adapter_desc
https://stackoverflow.com/questions/...r-amd/56599035

Also found this Visual Basic code so I translated it to pascal so here

Code:
uses
  Winapi.Windows, Winapi.DXGI;

type
  TGPUInfo = record
    FName: String;
    FSize: Integer;
  end;

  TGPUs = array of TGPUInfo;

procedure GetGPUs(out V: TGPUs);
  function Align(Value, Size: Integer): Integer;
  begin
    if Value mod Size <> 0 then
      Result := Succ(Max(0, Value div Size)) * Size
    else
      Result := Value;
  end;

var
  GPUInfo: TGPUInfo;
  i: Integer;
  riid: TGUID;
  hr: HRESULT;
  pFactory: IDXGIFactory;
  pAdapter: IDXGIAdapter;
  dxAdapterDesc: DXGI_ADAPTER_DESC;
begin
  riid := StringToGUID('{7b7166ec-21c7-44ae-b21a-c9ae321ae369}');
  pFactory := nil;
  hr := CreateDXGIFactory(riid, pFactory);
  if (hr = S_OK) and Assigned(pFactory) then
  begin
    pAdapter := nil;
    i := 0;
    while (pFactory.EnumAdapters(i, pAdapter) = S_OK) do
    begin
      FillChar(dxAdapterDesc, SizeOf(DXGI_ADAPTER_DESC), 0);
      hr := pAdapter.GetDesc(dxAdapterDesc);
      if hr = S_OK then
      begin
        GPUInfo.FName := dxAdapterDesc.Description;
        GPUInfo.FSize := IfThen(dxAdapterDesc.DedicatedVideoMemory = 0,
          dxAdapterDesc.DedicatedSystemMemory,
          dxAdapterDesc.DedicatedVideoMemory) div 1048576;
        GPUInfo.FSize := Align(GPUInfo.FSize, IfThen(GPUInfo.FSize < 512,
          32, 512));
        Insert(GPUInfo, V, Length(V));
      end;
      inc(i);
    end;
  end;
end;

procedure TForm1.Button1Click(Sender: TObject);
var
  i: Integer;
  MyGPUs: TGPUs;
begin
  GetGPUs(MyGPUs);
  for i := Low(MyGPUs) to High(MyGPUs) do
    ShowMessage(MyGPUs[i].FName + ' (' + MyGPUs[i].FSize.ToString + ' MB)');
end;
Quote:
Would this method work with older operating systems like WindowsXP or Vista, 7, etc?
This works using DXGI which was introduced in Windows Vista.

Quote:
The value in DedicatedVideoMemory is not correct here.
It should be 4 GB but it results 4239917056 = 4043.5 MB = 3.94 GB.
Actually it is correct, open task manager and you'll see why it is 3.94 GB, I added the align function to help with rounding off 4044 to 4096
Attached Images
File Type: png 59.PNG (54.2 KB, 133 views)

Last edited by Razor12911; 30-05-2020 at 18:13.
Reply With Quote