View Single Post
  #22  
Old 30-05-2020, 19:09
Cesar82's Avatar
Cesar82 Cesar82 is offline
Registered User
 
Join Date: May 2011
Location: Brazil
Posts: 1,073
Thanks: 1,814
Thanked 2,303 Times in 786 Posts
Cesar82 is on a distinguished road
You have correctly displayed the value of the main video card.

Did not detect Intel (R) HD Graphics 4000


Did something go wrong with my adaptation?
Or maybe the DXGI I used doesn't work for that.
Code:
uses
  Windows, DXGI;
  //DXGI from link

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

  TGPUs = array of TGPUInfo;

procedure GetGPUs(out V: TGPUs);
  function Max(A, B: Integer): Integer;
  begin
    if A > B then
      Result := A
    else
      Result := B;
  end;
  function Align(Value, Size: Integer): Integer;
  begin
    if Value <> 0 then
      Result := (Max(0, Value div Size) + 1) * Size
    else
      Result := Value;
  end;
var
  GPUInfo: TGPUInfo;
  i: Integer;
  riid: TGUID;
  hr: HRESULT;
  pFactory: IDXGIFactory;
  pAdapter: IDXGIAdapter;
  dxAdapterDesc: TDXGI_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(TDXGI_ADAPTER_DESC), 0);
      hr := pAdapter.GetDesc(dxAdapterDesc);
      if hr = S_OK then
      begin
        GPUInfo.FName := dxAdapterDesc.Description;

        if dxAdapterDesc.DedicatedVideoMemory = 0 then
          GPUInfo.FSize := dxAdapterDesc.DedicatedSystemMemory div 1048576
        else
          GPUInfo.FSize := dxAdapterDesc.DedicatedVideoMemory div 1048576;

        if GPUInfo.FSize < 512 then
          GPUInfo.FSize := Align(GPUInfo.FSize, 32)
        else
          GPUInfo.FSize := Align(GPUInfo.FSize, 512);

        SetLength(V, Length(V) + 1);
        V[Length(V) - 1] := GPUInfo;
      end;
      Inc(i);
    end;
  end;
end;

procedure TForm2.Button1Click(Sender: TObject);
var
  i: Integer;
  MyGPUs: TGPUs;
begin
  GetGPUs(MyGPUs);
  for i := Low(MyGPUs) to High(MyGPUs) do
    ShowMessage(MyGPUs[i].FName + ' (' + IntToStr(MyGPUs[i].FSize) + ' MB)');
end;
Reply With Quote