Go Back   FileForums > Game Backup > PC Games > PC Games - CD/DVD Conversions > Conversion Tutorials
Register FAQ Community Calendar Today's Posts Search

 
 
Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #25  
Old 31-05-2020, 06:02
Razor12911's Avatar
Razor12911 Razor12911 is offline
Noob
 
Join Date: Jul 2012
Location: South Africa
Posts: 3,762
Thanks: 2,194
Thanked 11,261 Times in 2,320 Posts
Razor12911 is on a distinguished road
try this one, you can remove the DXGI code if you having issues and just use the registry. Should produce the same results.

Code:
uses
Winapi.Windows, Winapi.DXGI, System.Win.Registry;

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

  TGPUs = array of TGPUInfo;

procedure GetGPUs(out V: TGPUs; UseDXGI: Boolean);
  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;

const
  RegPath = 'SOFTWARE\Microsoft\DirectX\';
var
  GPUInfo: TGPUInfo;
  i, j, k, l: Integer;
  x: Int64;
  riid: TGUID;
  hr: HRESULT;
  pFactory: IDXGIFactory;
  pAdapter: IDXGIAdapter;
  dxAdapterDesc: DXGI_ADAPTER_DESC;
  Reg1: TRegIniFile;
  Reg2: TRegistry;
  SL: TStringList;
  mybool: Boolean;
begin
  Reg1 := TRegIniFile.Create(KEY_READ or KEY_WOW64_64KEY);
  SL := TStringList.Create;
  Reg1.RootKey := HKEY_LOCAL_MACHINE;
  if Reg1.OpenKey(RegPath, False) then
    Reg1.ReadSections(SL);
  Reg1.Free;
  Reg2 := TRegistry.Create(KEY_READ or KEY_WOW64_64KEY);
  Reg2.RootKey := HKEY_LOCAL_MACHINE;
  if UseDXGI then
  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) shr 20;
          if dxAdapterDesc.DedicatedSystemMemory = 0 then
            for j := 0 to SL.Count - 1 do
            begin
              if Reg2.OpenKey(RegPath + SL[j], False) then
              begin
                if (Reg2.ReadString('Description') = GPUInfo.FName) then
                  if Reg2.ReadBinaryData('DedicatedVideoMemory', x, x.Size) = x.Size
                  then
                  begin
                    GPUInfo.FSize := x shr 20;
                    break;
                  end;
                Reg2.CloseKey;
              end;
            end;
          GPUInfo.FSize := Align(GPUInfo.FSize, IfThen(GPUInfo.FSize < 512,
            32, 512));
          Insert(GPUInfo, V, Length(V));
        end;
        inc(i);
      end;
    end;
  end;
  for j := 0 to SL.Count - 1 do
  begin
    if Reg2.OpenKey(RegPath + SL[j], False) then
    begin
      mybool := True;
      for i := Low(V) to High(V) do
      begin
        if (Reg2.ReadString('Description') = V[i].FName) then
        begin
          mybool := False;
          break;
        end;
      end;
      if mybool then
      begin
        GPUInfo.FName := Reg2.ReadString('Description');
        x := 0;
        if Reg2.ReadBinaryData('DedicatedVideoMemory', x, x.Size) = x.Size then
          x := x shr 20;
        if x = 0 then
          if Reg2.ReadBinaryData('DedicatedSystemMemory', x, x.Size) = x.Size
          then
            x := x shr 20;
        GPUInfo.FSize := x;
        GPUInfo.FSize := Align(GPUInfo.FSize, IfThen(GPUInfo.FSize < 512,
          32, 512));
        Insert(GPUInfo, V, Length(V));
      end;
    end;
    Reg2.CloseKey;
  end;
  SL.Free;
  Reg2.Free;
  for i := Low(V) to High(V) do
  begin
    k := 0;
    for j := Low(V) to High(V) do
      if V[j].FSize >= k then
      begin
        k := V[i].FSize;
        l := j
      end;
    GPUInfo := V[i];
    V[i] := V[l];
    V[l] := GPUInfo;
  end;
end;

procedure TForm1.Button1Click(Sender: TObject);
var
  i: Integer;
  MyGPUs: TGPUs;
begin
  Memo1.Lines.Clear;
  GetGPUs(MyGPUs, True);
  for i := Low(MyGPUs) to High(MyGPUs) do
    Memo1.Lines.Add(MyGPUs[i].FName + ' (' + MyGPUs[i].FSize.ToString + ' MB)');
end;
Attached Images
File Type: png 60.PNG (5.7 KB, 180 views)
Attached Files
File Type: 7z Project1.7z (1.97 MB, 65 views)

Last edited by Razor12911; 31-05-2020 at 06:43.
Reply With Quote
The Following 5 Users Say Thank You to Razor12911 For This Useful Post:
audiofeel (04-07-2026), BLACKFIRE69 (31-05-2020), Cesar82 (31-05-2020), Harsh ojha (31-05-2020), Jiva newstone (31-05-2020)
 


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Nero Plugin to burn mdf/mds images Kall CD/DVD Software & Utilities 6 09-11-2007 02:29
REQUEST : SDF plugin and AHX tool --=FamilyGuy=-- DC Games 4 20-04-2007 13:13
is there a a gamecube plugin to 3d studio max gamesmell GameCube Games 1 12-03-2004 23:54
FlaskMPEG & Panasonic Plugin: Plugin has "Fatal Error" dan CD/DVD Software & Utilities 1 15-11-2000 16:23



All times are GMT -7. The time now is 10:13.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
FileForums @ https://fileforums.com