Thema: SSD erkennen?

Einzelnen Beitrag anzeigen

t.roller
(Gast)

n/a Beiträge
 
#30

AW: SSD erkennen?

  Alt 5. Jun 2016, 16:52
Ab WINDOWS8 gibt es über WMI mehr Informationen, siehe:

MSFT_PhysicalDisk class

MediaType
Data type: UInt16
Access type: Read-only
The media type of the physical disk.
Value Meaning
0 Unspecified
3 HDD
4 SSD

SpindleSpeed
Data type: UInt32
Access type: Read-only
Qualifiers: Required, Units ("RPM")
The rotational speed of spindle-based physical disks. For solid
state devices (SSDs) or other non-rotational media, this member
should be set to 0. For rotating media that has an unknown speed,
this member should be set to 0xFFFFFFFF (UINT32_MAX).

Beispiel geht auch OHNE Administrator-Rechte und bei USB-Disks.
Delphi-Quellcode:
// This code was generated by the Wmi Delphi Code Creator http://theroadtodelphi.wordpress.com
// Version: 1.8.3.0
// LIABILITY DISCLAIMER
// THIS GENERATED CODE IS DISTRIBUTED "AS IS". NO WARRANTY OF ANY KIND IS EXPRESSED OR IMPLIED.
// YOU USE IT AT YOUR OWN RISK. THE AUTHOR NOT WILL BE LIABLE FOR DATA LOSS,
// DAMAGES AND LOSS OF PROFITS OR ANY OTHER KIND OF LOSS WHILE USING OR MISUSING THIS CODE.
program WMI_PhysicalDisk;

{$APPTYPE CONSOLE}

uses
 // SysUtils, ActiveX, ComObj, Variants;
  System.SysUtils,
  Winapi.ActiveX,
  System.Win.ComObj,
  System.Variants;

function VarToInt(const AVariant: Variant): INT64;// integer;
begin Result := StrToIntDef(Trim(VarToStr(AVariant)), 0); end;

procedure GetMSFT_PhysicalDiskInfo;
const
  WbemUser =''; WbemPassword =''; WbemComputer ='localhost';
  wbemFlagForwardOnly = $00000020;
var
  FSWbemLocator : OLEVariant;
  FWMIService : OLEVariant;
  FWbemObjectSet: OLEVariant;
  FWbemObject : OLEVariant;
  oEnum : IEnumvariant;
  iValue : LongWord;
begin;
  FSWbemLocator := CreateOleObject('WbemScripting.SWbemLocator');
  FWMIService := FSWbemLocator.ConnectServer(WbemComputer, 'root\Microsoft\Windows\Storage', WbemUser, WbemPassword);
  FWbemObjectSet:= FWMIService.ExecQuery('SELECT * FROM MSFT_PhysicalDisk','WQL',wbemFlagForwardOnly);
  oEnum := IUnknown(FWbemObjectSet._NewEnum) as IEnumVariant;
  while oEnum.Next(1, FWbemObject, iValue) = 0 do
  begin
    Writeln(Format('AllocatedSize %d',[VarToInt(FWbemObject.AllocatedSize)]));// Uint64
    Writeln(Format('BusType %d',[VarToInt(FWbemObject.BusType)]));// Uint16
// Writeln(Format('CannotPoolReason %d',[VarToInt(FWbemObject.CannotPoolReason)]));// Array of Uint16
    Writeln(Format('CanPool %s',[VarToStr(FWbemObject.CanPool)]));// Boolean
    Writeln(Format('Description %s',[VarToStr(FWbemObject.Description)]));// String
    Writeln(Format('DeviceId %s',[VarToStr(FWbemObject.DeviceId)]));// String
    Writeln(Format('EnclosureNumber %d',[VarToInt(FWbemObject.EnclosureNumber)]));// Uint16
    Writeln(Format('FirmwareVersion %s',[VarToStr(FWbemObject.FirmwareVersion)]));// String
    Writeln(Format('FriendlyName %s',[VarToStr(FWbemObject.FriendlyName)]));// String
    Writeln(Format('HealthStatus %d',[VarToInt(FWbemObject.HealthStatus)]));// Uint16
    Writeln(Format('IsIndicationEnabled %s',[VarToStr(FWbemObject.IsIndicationEnabled)]));// Boolean
    Writeln(Format('IsPartial %s',[VarToStr(FWbemObject.IsPartial)]));// Boolean
    Writeln(Format('LogicalSectorSize %d',[VarToInt(FWbemObject.LogicalSectorSize)]));// Uint64
    Writeln(Format('Manufacturer %s',[VarToStr(FWbemObject.Manufacturer)]));// String
    Writeln(Format('MediaType %d',[VarToInt(FWbemObject.MediaType)]));// Uint16
    Writeln(Format('Model %s',[VarToStr(FWbemObject.Model)]));// String
    Writeln(Format('ObjectId %s',[VarToStr(FWbemObject.ObjectId)]));// String
// Writeln(Format('OperationalStatus %d',[VarToInt(FWbemObject.OperationalStatus)]));// Array of Uint16
    Writeln(Format('OtherCannotPoolReasonDescription %s',[VarToStr(FWbemObject.OtherCannotPoolReasonDescription)]));// String
    Writeln(Format('PartNumber %s',[VarToStr(FWbemObject.PartNumber)]));// String
    Writeln(Format('PassThroughClass %s',[VarToStr(FWbemObject.PassThroughClass)]));// String
    Writeln(Format('PassThroughIds %s',[VarToStr(FWbemObject.PassThroughIds)]));// String
    Writeln(Format('PassThroughNamespace %s',[VarToStr(FWbemObject.PassThroughNamespace)]));// String
    Writeln(Format('PassThroughServer %s',[VarToStr(FWbemObject.PassThroughServer)]));// String
    Writeln(Format('PhysicalLocation %s',[VarToStr(FWbemObject.PhysicalLocation)]));// String
    Writeln(Format('PhysicalSectorSize %d',[VarToInt(FWbemObject.PhysicalSectorSize)]));// Uint64
    Writeln(Format('SerialNumber %s',[VarToStr(FWbemObject.SerialNumber)]));// String
    Writeln(Format('Size %d',[VarToInt(FWbemObject.Size)]));// Uint64
    Writeln(Format('SlotNumber %d',[VarToInt(FWbemObject.SlotNumber)]));// Uint16
    Writeln(Format('SoftwareVersion %s',[VarToStr(FWbemObject.SoftwareVersion)]));// String
    Writeln(Format('SpindleSpeed %d',[VarToInt(FWbemObject.SpindleSpeed)]));// Uint32
// Writeln(Format('SupportedUsages %d',[VarToInt(FWbemObject.SupportedUsages)]));// Array of Uint16
    Writeln(Format('UniqueId %s',[VarToStr(FWbemObject.UniqueId)]));// String
    Writeln(Format('Usage %d',[VarToInt(FWbemObject.Usage)]));// Uint16

    Writeln('-------------------------------------------------------------------');
    FWbemObject:=Unassigned;
  end;
end;
begin
 try
    CoInitialize(nil);
    try
      GetMSFT_PhysicalDiskInfo;
    finally
      CoUninitialize;
    end;
 except
    on E:EOleException do
        Writeln(Format('EOleException %s %x', [E.Message,E.ErrorCode]));
    on E:Exception do
        Writeln(E.Classname, ':', E.Message);
 end;
 Writeln('Press Enter to exit');
 Readln;
end.
Beispiel-Ausgabe: PhysicalDisk1 = SSD/USB, PhysicalDisk0 = HDD0

AllocatedSize 0
BusType 7
CanPool False
Description
DeviceId 1
EnclosureNumber 0
FirmwareVersion 3004
FriendlyName PhysicalDisk1
HealthStatus 0
IsIndicationEnabled
IsPartial True
LogicalSectorSize 512
Manufacturer KINGSTON
MediaType 0
Model SV300S37A240G
OtherCannotPoolReasonDescription
PartNumber
PassThroughClass
PassThroughIds
PassThroughNamespace
PassThroughServer
PhysicalLocation
PhysicalSectorSize 512
SerialNumber 00A1234xxxxxx
Size 0
SlotNumber 0
SoftwareVersion
SpindleSpeed -1
UniqueId
Usage 1
--------------------------------------------------
AllocatedSize 0
BusType 11
CanPool False
Description
DeviceId 0
EnclosureNumber 0
FirmwareVersion 2BC10001
FriendlyName PhysicalDisk0
HealthStatus 0
IsIndicationEnabled
IsPartial True
LogicalSectorSize 512
Manufacturer
MediaType 3
Model ST2000LM003 HN-M201RAD
OtherCannotPoolReasonDescription
PartNumber
PassThroughClass
PassThroughIds
PassThroughNamespace
PassThroughServer
PhysicalLocation
PhysicalSectorSize 4096
SerialNumber S346J9xxxxxxxx
Size 0
SlotNumber 0
SoftwareVersion
SpindleSpeed -1
UniqueId 50004xxxxxxxxx
Usage 1
--------------------------------------------------

Geändert von t.roller ( 5. Jun 2016 um 17:56 Uhr)
  Mit Zitat antworten Zitat