Einzelnen Beitrag anzeigen

kumar89
(Gast)

n/a Beiträge
 
#20

Re: Auslesen der Mainboard Seriennummer

  Alt 15. Jun 2009, 15:10
ok ich bin weiter gekommen

http://msdn.microsoft.com/en-us/library/aa394072.aspx


was muss ich raus nehmen (siehe link) um die seriennummer des mainboards zu bekommen.


Delphi-Quellcode:
function QueryWMI(const QueryClass, QueryProperty: String; AStrings: TStrings): Boolean;
  var
    Locator: ISWbemLocator;
    Services: ISWbemServices;
    ObjectSet: ISWbemObjectSet;
    WMIObject: ISWbemObject;
    WMIProperty: ISWbemProperty;
    Enum: IEnumVariant;
    ObjValue: Cardinal;
    TempObj: OleVariant;
begin
  Result := FALSE;
  try
    Locator := CoSWbemLocator.Create;
    try
      Services := Locator.ConnectServer('', 'root\cimv2', '', '', '','', 0, NIL);
      if Assigned(Services) then begin
        Services.Security_.ImpersonationLevel := 3;
        ObjectSet := Services.ExecQuery('SELECT * FROM '+QueryClass,
                                        'WQL',
                                         wbemFlagForwardOnly or wbemFlagReturnWhenComplete,
                                         NIL);
        Enum := (ObjectSet._NewEnum) as IEnumVariant;
        while (Enum.Next(1, TempObj, ObjValue) = S_OK) do begin
          try
            WMIObject := IUnknown(TempObj) as ISWBemObject;
          except
            WMIObject := NIL;
          end;
          TempObj := Unassigned; // Interface in TempObj freigeben
          if Assigned(WMIObject) then begin
            WMIProperty := WMIObject.Properties_.Item(QueryProperty, 0);
            if (NOT VarIsNull(WMIProperty.Get_Value)) then
              AStrings.Add(Trim(WMIProperty.Get_Value));
          end;
        end;
        Result := TRUE;
      end;
    finally
      Services := NIL;
      Locator := NIL;
    end;
  except // Exceptions fangen (Wenn WMI nicht verfügbar/installiert ist, gibt´s eine!)
    Result := FALSE;
  end;
end;

procedure TfrmSystemInfo.Button1Click(Sender: TObject);
begin
     QueryWMI('Win32_VideoController','Caption',Systemauswertung.Lines);
end;

Mit freundlichen Grüßen


Kumar89
  Mit Zitat antworten Zitat