Einzelnen Beitrag anzeigen

Alter Mann

Registriert seit: 15. Nov 2003
Ort: Berlin
946 Beiträge
 
Delphi 10.2 Tokyo Professional
 
#4

Re: Name der Grafikkarte auslesen, wie?

  Alt 31. Jan 2004, 19:03
Hi, Delphi-Noobie,

ich hoffe Du bist es Wert

Delphi-Quellcode:

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;

type
  TForm1 = class(TForm)
    ListBox1: TListBox;
    procedure FormCreate(Sender: TObject);
  private
    { Private-Deklarationen }
    RegConst : String;
    procedure FillList;
  public
    { Public-Deklarationen }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

uses Registry;

procedure TForm1.FormCreate(Sender: TObject);
begin
  if Win32Platform = VER_PLATFORM_WIN32_WINDOWS   then RegConst := 'Enum\PCI';
  if Win32Platform = VER_PLATFORM_WIN32_NT   then RegConst := 'SYSTEM\CurrentControlSet\Enum\PCI';
  FillList;
end;

procedure TForm1.FillList;
var
  Reg,
  Entry,
  Items : TRegistry;
  RegEntries,
  EntryList,
  ItemList : TStringList;
  R, E, I : Integer;
  S : String;
begin
  Reg := TRegistry.Create(KEY_ALL_ACCESS);
  try
    Reg.RootKey := HKEY_LOCAL_MACHINE;
    if Reg.OpenKeyReadOnly(RegConst) then
    begin
      RegEntries := TStringList.Create;
      try
        Reg.GetKeyNames(RegEntries);
        Reg.CloseKey;
        for R := 0 to RegEntries.Count - 1 do
        begin
          Entry := TRegistry.Create(KEY_ALL_ACCESS);
          try
             Entry.RootKey := HKEY_LOCAL_MACHINE;
             if Entry.OpenKeyReadOnly(RegConst + '\' + RegEntries.Strings[R]) then
             begin
               EntryList := TStringList.Create;
               Entry.GetKeyNames(EntryList);
               Entry.CloseKey;
               for E := 0 to EntryList.Count - 1 do
               begin
                 Items := TRegistry.Create(KEY_ALL_ACCESS);
                 try
                    Items.RootKey := HKEY_LOCAL_MACHINE;
                    if Items.OpenKeyReadOnly(RegConst + '\' + RegEntries.Strings[R] + '\' + EntryList.Strings[E]) then
                    begin
                      ItemList := TStringList.Create;
                      Items.GetValueNames(ItemList);
                      S := Items.ReadString('FriendlyName');
                      if S = 'then
                      S := Items.ReadString('DeviceDesc');
                      if ListBox1.Items.IndexOf(S) = -1 then ListBox1.Items.Add(S);
                      Items.CloseKey;
                    end;
                 finally
                    Items.Free;
                 end;
               end;
               Entry.CloseKey;
             end;
          finally
             Entry.Free;
          end;
        end;
      finally
         RegEntries.Free;
      end;
    end;
  finally
     Reg.Free;
  end;
end;

end.
Die lauffähige Variante gibt es hier:
Angehängte Dateien
Dateityp: zip delphinoobie.zip (6,6 KB, 61x aufgerufen)
  Mit Zitat antworten Zitat