Autor Beitrag
Biarchiv
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 688



BeitragVerfasst: Mi 15.07.09 14:54 
Hallo,

gibts zufällig eine API wo ich den Festplatten-Namen (zB: MAXTOR SF800) ermitteln kann?
Was halt im Geräte-Mananger im Treeview aufpopen kann.


Moderiert von user profile iconNarses: Topic aus Sonstiges (Delphi) verschoben am Mi 15.07.2009 um 15:05
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10183
Erhaltene Danke: 1256

W10ent
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Mi 15.07.09 15:06 
Moin!

Schonmal in den WMI-Klassen gestöbert? Da ist doch fast alles zu finden. ;) :idea:

cu
Narses

_________________
There are 10 types of people - those who understand binary and those who don´t.
Biarchiv Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 688



BeitragVerfasst: Mi 15.07.09 15:38 
Hallo,

leider nichts passendes gefunden.
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10183
Erhaltene Danke: 1256

W10ent
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Mi 15.07.09 17:41 
Moin!

user profile iconBiarchiv hat folgendes geschrieben Zum zitierten Posting springen:
leider nichts passendes gefunden.
Aha, wo hast du denn gesucht? :gruebel: WMI Klassenreferenz

cu
Narses

_________________
There are 10 types of people - those who understand binary and those who don´t.
hathor
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Do 16.07.09 04:34 
uranop
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 149

Win XP, Win 7, Slackware 11, FreeBSD
D6E, php
BeitragVerfasst: Do 16.07.09 05:57 
besorge dir dir die wmi "compomente" von magenta systems

>> www.magsys.co.uk/delphi/magwmi.asp

>> www.magsys.co.uk/dow...oftware/magwmi52.zip

da is ne demo dabei wo du im vorfeld alles an guggen kannst.


in deinem proj kannste einfach die unit einbinden,

mit einer kleinen funktion

ala

ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
function GetWMIinfo(wmiHost, wmiClass, wmiProperty : string):string;
var  // These are all needed for the WMI querying process
  Locator:  ISWbemLocator;
  Services: ISWbemServices;
  SObject:  ISWbemObject;
  ObjSet:   ISWbemObjectSet;
  SProp:    ISWbemProperty;
  Enum:     IEnumVariant;
  Value:    Cardinal;
  TempObj:  OleVariant;
  SN: string;
begin
  try
  Locator := CoSWbemLocator.Create;  // Create the Location object
  // Connect to the WMI service, with the root\cimv2 namespace
   Services :=  Locator.ConnectServer(wmiHost, 'root\cimv2''''''',''0nil);
  ObjSet := Services.ExecQuery('SELECT * FROM '+wmiClass+'''WQL',
    wbemFlagReturnImmediately and wbemFlagForwardOnly , nil);
  Enum :=  (ObjSet._NewEnum) as IEnumVariant;
  while (Enum.Next(1, TempObj, Value) = S_OK) do
  begin
    SObject := IUnknown(tempObj) as ISWBemObject;
    SProp := SObject.Properties_.Item(wmiProperty, 0);
    if VarIsNull(SProp.Get_Value) then
      result := ''
    else
    begin
      SN := SProp.Get_Value;
      result :=  SN;
    end;
  end;
  except // Trap any exceptions (Not having WMI installed will cause one!)
   on exception do
    result := '';
   end;
end;

// waere der name der eingebauten platten unter localhost
Label.Caption := GetWMIinfo('','Win32_DiskDrive','Caption');



mit dem spielzeug kann man so ziemlich alles machen.

gruß
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19313
Erhaltene Danke: 1747

W11 x64 (Chrome, Edge)
Delphi 11 Pro, Oxygene, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Do 16.07.09 06:00 
Ich habe das gerade erst selbst gemacht. Schau noch einmal in die WMI-Referenz. Du kannst dort die Festplatten mit Modellnummern auslesen und auch eine Liste aller Partitionen und logischer Laufwerke usw. und auch welche davon zu welcher Festplatte gehören...

Das angehängte Zip-Archiv greift, wenn ich das beim schnellen Blick richtig gesehen habe, direkt auf die Platte zu dafür, das ist eigentlich gar nicht notwendig, da Windows selbst die Daten in der WMI-Datenbank hat.

user profile iconuranop hat folgendes geschrieben Zum zitierten Posting springen:
mit einer kleinen funktion [...]
Aua, der Autor dieser Funktion hat die Exceptionblöcke nicht so sinnvoll gesetzt (bzw. fast gar nicht)...
So sollte es sauber sein:
www.delphi-forum.de/....php?p=551899#551899
uranop
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 149

Win XP, Win 7, Slackware 11, FreeBSD
D6E, php
BeitragVerfasst: Do 16.07.09 06:04 
xD das ist original von DENEN .. bin mir keiner Schuld bewusst : P

EDIT: aber danke für den hinweis ... dann werde ich meine abfragen dahingebend mal optimieren
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19313
Erhaltene Danke: 1747

W11 x64 (Chrome, Edge)
Delphi 11 Pro, Oxygene, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Do 16.07.09 06:09 
Wobei diese Vorgehensweise für die Abfrage mehrerer Werte in "einer Zeile" sehr ungünstig ist. Da wäre es sinnvoller, direkt dort weitere Abfragen zu machen, wo hier nur der eine Wert abgefragt wird. Das beschleunigt das ganze enorm.

So habe ich es auch in meinem kleinen Systeminfo-Tool gemacht gehabt. Ich habe die Anfrage einfach etwas verteilt und an der Stelle via Callback gleich alle Werte auf einmal abfragen lassen.
uranop
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 149

Win XP, Win 7, Slackware 11, FreeBSD
D6E, php
BeitragVerfasst: Do 16.07.09 06:52 
ack,
aber man kann mit bissl umschrieben des ganzen
genauere Bedingungen erschaffen ...

meine funktion hat nun mittlerweile feste "where" strukturen etc in sich ...