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 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90
|
// -----------------------------------------------------------------------------------------------------
// This code was generated by the Wmi Delphi Code Creator (WDCC) Version 1.9.9.482
// http://code.google.com/p/wmi-delphi-code-creator/
// Blog http://theroadtodelphi.wordpress.com/wmi-delphi-code-creator/
// Author Rodrigo Ruz V. (RRUZ) Copyright (C) 2011-2015
// -----------------------------------------------------------------------------------------------------
//
// 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 GestionMoniteurs;
{$APPTYPE CONSOLE}
uses
SysUtils,
ActiveX,
ComObj,
Variants;
function OleVariantArrayUInt16ToString(const PostData: OleVariant): string;
var
K: Integer;
begin
//Result := '';
if VarIsNull(PostData) then
Exit('');
for K := VarArrayLowBound(PostData, 1) to VarArrayHighBound(PostData, 1) do
Result := Concat(Result, Chr(UInt16(PostData[K])));
Result := Trim(Result);
end;
// Monitor ID
procedure GetWmiMonitorIDInfo;
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\WMI', WbemUser, WbemPassword);
FWbemObjectSet := FWMIService.ExecQuery('SELECT * FROM WmiMonitorID', 'WQL', wbemFlagForwardOnly);
oEnum := IUnknown(FWbemObjectSet._NewEnum) as IEnumvariant;
while oEnum.Next(1, FWbemObject, iValue) = 0 do
begin
Writeln(Format('Active : %s', [String(FWbemObject.Active)])); // Boolean
Writeln(Format('InstanceName : %s', [String(FWbemObject.InstanceName)])); // String
Writeln(Format('ManufacturerName : %s', [OleVariantArrayUInt16ToString(FWbemObject.ManufacturerName)]));// Array of Uint16
Writeln(Format('ProductCodeID : %s', [OleVariantArrayUInt16ToString(FWbemObject.ProductCodeID)])); // Array of Uint16
Writeln(Format('SerialNumberID : %s', [OleVariantArrayUInt16ToString(FWbemObject.SerialNumberID)])); // Array of Uint16
Writeln(Format('UserFriendlyName : %s', [OleVariantArrayUInt16ToString(FWbemObject.UserFriendlyName)])); // Array of Uint16
Writeln(Format('WeekOfManufacture : %d', [Integer(FWbemObject.WeekOfManufacture)])); // Uint8
Writeln(Format('YearOfManufacture : %d', [Integer(FWbemObject.YearOfManufacture)])); // Uint16
Writeln('');
FWbemObject := Unassigned;
end;
end;
begin
try
CoInitialize(nil);
try
GetWmiMonitorIDInfo;
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. |
Partager