
OleCheck(MkParseDisplayName(BindCtx, StringToOleStr(objectName), chEaten, Moniker)) Result := Result+'|'+_VarToStr(vArray) įunction VarStrNull(const V:OleVariant):string //avoid problems with null stringsįunction GetWMIObject(const objectName: String): IDispatch //create the Wmi instance VarArray : Result := VarArrayToStr(Variant(V)) įor i := VarArrayLowBound(vArray, 1) to VarArrayHighBound(vArray, 1) do VarVariant : Result := VarToStr(Variant(V)) VarCurrency : Result := FloatToStr(Double(V)) VarInteger : Result := IntToStr(integer(V)) program GetWMI_Info įunction VarArrayToStr(const vArray: variant): string įunction _VarToStr(const V: variant): string This is the code to obtain the serial number of a usb using the Win32_DiskDrive class. Win32_DiskPartition -> Win32_LogicalDiskToPartition -> Win32_DiskDrive the sequence to find this association is like this. So you must find this link previous to obtain the serial number. Now the bad news, unfortunately this classes is not associated directly with the letter (C,D,E,F.) of the logical disk, because that you must call to another wmi classes to find the link between the logical driver letter and the Physical drive. these classes are Win32_DiskDrive and Win32_PhysicalMedia. The good news are which exist two wmi classes wich exposes a property called SerialNumber which store the Number allocated by the manufacturer to identify the physical media. Opc0de, according to your comments i will give you a sample using the WMI.įirst, the code which you posted (using the GetVolumeInformation function) return the serial number assigned by windows when you format a disk.
