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 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327
|
//-----------------------------------------------------------------------------------------------------
// 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 GetWMI_Info;
{$APPTYPE CONSOLE}
uses
windows,
SysUtils,
ActiveX,
ComObj,
Variants;
function ConsoleString(const Chaine: string): string;
begin
{$ifdef unicode}
Result := Chaine;
{$else}
SetLength(Result, Length(Chaine));
if Chaine <> EmptyStr then
CharToOem(PChar(Chaine), PChar(Result));
{$endif}
end;
function VarToString(aVariant: Variant): string;
begin
Result := ConsoleString(VarToStr(aVariant));
end;
function VarToBoolString(aVariant: Variant): string;
begin
if not VarIsNull(aVariant) then
Result := BoolToStr(aVariant, True)
else
Result := '';
end;
function VarToInteger(aVariant: Variant): Integer;
begin
if not VarIsNull(aVariant) then
Result := Integer(aVariant)
else
Result := 0;
end;
function GetDataExecutionPrevention_SupportPolicyAsString(const ReturnValue: Integer): string;
begin
Result := '';
case ReturnValue of
0: Result := 'Always Off';
1: Result := 'Always On';
2: Result := 'Opt In';
3: Result := 'Opt Out';
end;
end;
function GetEncryptionLevelAsString(const ReturnValue: Integer): string;
begin
Result := '';
case ReturnValue of
0: Result := '40 bits';
1: Result := '128 bits';
2: Result := 'n bits';
end;
end;
function GetForegroundApplicationBoostAsString(const ReturnValue: Integer): string;
begin
Result := '';
case ReturnValue of
0: Result := 'Aucun';
1: Result := 'Minimum';
2: Result := 'Maximum';
end;
end;
function GetLargeSystemCacheAsString(const ReturnValue: Integer): string;
begin
Result := '';
case ReturnValue of
0: Result := 'Optimiser pour les applications';
1: Result := 'Optimiser pour les performances système';
end;
Result := ConsoleString(Result);
end;
function GetOperatingSystemSKUAsString(const ReturnValue: Integer): string;
begin
Result := '';
case ReturnValue of
0: Result := 'Non défini';
1: Result := 'Édition Intégrale';
2: Result := 'Édition Familiale Basique';
3: Result := 'Édition Familiale Premium';
4: Result := 'Entreprise';
5: Result := 'Édition Familiale Basique N';
6: Result := 'Professionnel';
7: Result := 'Standard Server Edition';
8: Result := 'Datacenter Server Edition';
9: Result := 'Small Business Server Edition';
10: Result := 'Enterprise Server Edition';
11: Result := 'Starter Edition';
12: Result := 'Datacenter Server Core Edition';
13: Result := 'Standard Server Core Edition';
14: Result := 'Enterprise Server Core Edition';
15: Result := 'Enterprise Server IA64 Edition';
16: Result := 'Professionnel N';
17: Result := 'Web Server Edition';
18: Result := 'Cluster Server Edition';
19: Result := 'Édition Serveur personnel';
20: Result := 'Storage Express Server Edition';
21: Result := 'Storage Standard Server Edition';
22: Result := 'Storage Workgroup Server Edition';
23: Result := 'Storage Enterprise Server Edition';
24: Result := 'Server For Small Business Edition';
25: Result := 'Small Business Server Premium Edition';
end;
Result := ConsoleString(Result);
end;
function GetOSTypeAsString(const ReturnValue: Integer): string;
begin
Result := '';
case ReturnValue of
0: Result := 'Inconnu';
1: Result := 'Autre';
2: Result := 'MACOS';
3: Result := 'ATTUNIX';
4: Result := 'DGUX';
5: Result := 'DECNT';
6: Result := 'Digital Unix';
7: Result := 'OpenVMS';
8: Result := 'HPUX';
9: Result := 'AIX';
10: Result := 'MVS';
11: Result := 'OS400';
12: Result := 'OS/2';
13: Result := 'JavaVM';
14: Result := 'MSDOS';
15: Result := 'WIN3x';
16: Result := 'WIN95';
17: Result := 'WIN98';
18: Result := 'WINNT';
19: Result := 'WINCE';
20: Result := 'NCR3000';
21: Result := 'NetWare';
22: Result := 'OSF';
23: Result := 'DC/OS';
24: Result := 'Reliant UNIX';
25: Result := 'SCO UnixWare';
26: Result := 'SCO OpenServer';
27: Result := 'Sequent';
28: Result := 'IRIX';
29: Result := 'Solaris';
30: Result := 'SunOS';
31: Result := 'U6000';
32: Result := 'ASERIES';
33: Result := 'TandemNSK';
34: Result := 'TandemNT';
35: Result := 'BS2000';
36: Result := 'LINUX';
37: Result := 'Lynx';
38: Result := 'XENIX';
39: Result := 'VM/ESA';
40: Result := 'Interactive UNIX';
41: Result := 'BSDUNIX';
42: Result := 'FreeBSD';
43: Result := 'NetBSD';
44: Result := 'GNU Hurd';
45: Result := 'OS9';
46: Result := 'MACH Kernel';
47: Result := 'Inferno';
48: Result := 'QNX';
49: Result := 'EPOC';
50: Result := 'IxWorks';
51: Result := 'VxWorks';
52: Result := 'MiNT';
53: Result := 'BeOS';
54: Result := 'HP MPE';
55: Result := 'NextStep';
56: Result := 'PalmPilot';
57: Result := 'Rhapsody';
58: Result := 'Windows 2000';
59: Result := 'Dédié';
60: Result := 'OS/390';
61: Result := 'VSE';
62: Result := 'TPF';
end;
Result := ConsoleString(Result);
end;
function GetProductTypeAsString(const ReturnValue: Integer): string;
begin
Result := '';
case ReturnValue of
1: Result := 'Station de travail';
2: Result := 'Contrôleur de domaine';
3: Result := 'Serveur';
end;
Result := ConsoleString(Result);
end;
// La classe Win32_OperatingSystem représente un système dexploitation installé sur un ordinateur Win32. Tout système dexploitation qui peut être installé sur un système Win32 est un descendant (ou membre) de cette classe
// Exemple*: Microsoft Windows 95.
procedure GetWin32_OperatingSystemInfo;
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\CIMV2', WbemUser, WbemPassword);
FWbemObjectSet := FWMIService.ExecQuery('SELECT * FROM Win32_OperatingSystem', 'WQL', wbemFlagForwardOnly);
oEnum := IUnknown(FWbemObjectSet._NewEnum) as IEnumVariant;
while oEnum.Next(1, FWbemObject, iValue) = 0 do
begin
Writeln(Format('BootDevice %s', [VarToString(FWbemObject.BootDevice)])); // String
Writeln(Format('BuildNumber %s', [VarToString(FWbemObject.BuildNumber)])); // String
Writeln(Format('BuildType %s', [VarToString(FWbemObject.BuildType)])); // String
Writeln(Format('Caption %s', [VarToString(FWbemObject.Caption)])); // String
Writeln(Format('CodeSet %s', [VarToString(FWbemObject.CodeSet)])); // String
Writeln(Format('CountryCode %s', [VarToString(FWbemObject.CountryCode)])); // String
Writeln(Format('CreationClassName %s', [VarToString(FWbemObject.CreationClassName)])); // String
Writeln(Format('CSCreationClassName %s', [VarToString(FWbemObject.CSCreationClassName)])); // String
Writeln(Format('CSDVersion %s', [VarToString(FWbemObject.CSDVersion)])); // String
Writeln(Format('CSName %s', [VarToString(FWbemObject.CSName)])); // String
Writeln(Format('CurrentTimeZone %d', [VarToInteger(FWbemObject.CurrentTimeZone)])); // Sint16
Writeln(Format('DataExecutionPrevention_32BitApplications %s', [VarToString(FWbemObject.DataExecutionPrevention_32BitApplications)])); // Boolean
Writeln(Format('DataExecutionPrevention_Available %s', [VarToString(FWbemObject.DataExecutionPrevention_Available)])); // Boolean
Writeln(Format('DataExecutionPrevention_Drivers %s', [VarToString(FWbemObject.DataExecutionPrevention_Drivers)])); // Boolean
Writeln(Format('DataExecutionPrevention_SupportPolicy %s', [GetDataExecutionPrevention_SupportPolicyAsString(FWbemObject.DataExecutionPrevention_SupportPolicy)])); // Uint8
Writeln(Format('Debug %s', [VarToBoolString(FWbemObject.Debug)])); // Boolean
Writeln(Format('Description %s', [VarToString(FWbemObject.Description)])); // String
Writeln(Format('Distributed %s', [VarToBoolString(FWbemObject.Distributed)])); // Boolean
Writeln(Format('EncryptionLevel %s', [GetEncryptionLevelAsString(FWbemObject.EncryptionLevel)])); // Uint32
Writeln(Format('ForegroundApplicationBoost %s', [GetForegroundApplicationBoostAsString(FWbemObject.ForegroundApplicationBoost)])); // Uint8
Writeln(Format('FreePhysicalMemory %d', [VarToInteger(FWbemObject.FreePhysicalMemory)])); // Uint64
Writeln(Format('FreeSpaceInPagingFiles %d', [VarToInteger(FWbemObject.FreeSpaceInPagingFiles)])); // Uint64
Writeln(Format('FreeVirtualMemory %d', [VarToInteger(FWbemObject.FreeVirtualMemory)])); // Uint64
Writeln(Format('InstallDate %s', [VarToString((FWbemObject.InstallDate))])); // Datetime
Writeln(Format('LargeSystemCache %s', [GetLargeSystemCacheAsString(StrToIntDef(VarToStr(FWbemObject.LargeSystemCache), 0))])); // Uint32
Writeln(Format('LastBootUpTime %s', [VarToString(FWbemObject.LastBootUpTime)])); // Datetime
Writeln(Format('LocalDateTime %s', [VarToString(FWbemObject.LocalDateTime)])); // Datetime
Writeln(Format('Locale %s', [VarToString(FWbemObject.Locale)])); // String
Writeln(Format('Manufacturer %s', [VarToString(FWbemObject.Manufacturer)])); // String
Writeln(Format('MaxNumberOfProcesses %d', [VarToInteger(FWbemObject.MaxNumberOfProcesses)])); // Uint32
Writeln(Format('MaxProcessMemorySize %d', [VarToInteger(FWbemObject.MaxProcessMemorySize)])); // Uint64
Writeln(Format('MUILanguages %s', [string(VarArrayGet(FWbemObject.MUILanguages, [0]))])); // Array of String
Writeln(Format('Name %s', [VarToString(FWbemObject.Name)])); // String
Writeln(Format('NumberOfLicensedUsers %d', [VarToInteger(FWbemObject.NumberOfLicensedUsers)]));// Uint32
Writeln(Format('NumberOfProcesses %d', [VarToInteger(FWbemObject.NumberOfProcesses)])); // Uint32
Writeln(Format('NumberOfUsers %d', [VarToInteger(FWbemObject.NumberOfUsers)])); // Uint32
Writeln(Format('OperatingSystemSKU %s', [GetOperatingSystemSKUAsString(FWbemObject.OperatingSystemSKU)])); // Uint32
Writeln(Format('Organization %s', [VarToString(FWbemObject.Organization)])); // String
Writeln(Format('OSArchitecture %s', [VarToString(FWbemObject.OSArchitecture)])); // String
Writeln(Format('OSLanguage %d', [VarToInteger(FWbemObject.OSLanguage)])); // Uint32
Writeln(Format('OSProductSuite %d', [VarToInteger(FWbemObject.OSProductSuite)])); // Uint32
Writeln(Format('OSType %s', [GetOSTypeAsString(FWbemObject.OSType)])); // Uint16
Writeln(Format('OtherTypeDescription %s', [VarToString(FWbemObject.OtherTypeDescription)])); // String
Writeln(Format('PAEEnabled %s', [VarToBoolString(FWbemObject.PAEEnabled)])); // Boolean
Writeln(Format('PlusProductID %s', [VarToString(FWbemObject.PlusProductID)])); // String
Writeln(Format('PlusVersionNumber %s', [VarToString(FWbemObject.PlusVersionNumber)])); // String
{ "PortableOperatingSystem" non supporté sous Win7 }
// Writeln(Format('PortableOperatingSystem %s', [VarToString(FWbemObject.PortableOperatingSystem)]));// Boolean
Writeln(Format('Primary %s', [VarToString(FWbemObject.Primary)])); // Boolean
Writeln(Format('ProductType %s', [GetProductTypeAsString(FWbemObject.ProductType)])); // Uint32
Writeln(Format('RegisteredUser %s', [VarToString(FWbemObject.RegisteredUser)])); // String
Writeln(Format('SerialNumber %s', [VarToString(FWbemObject.SerialNumber)])); // String
Writeln(Format('ServicePackMajorVersion %d', [VarToInteger(FWbemObject.ServicePackMajorVersion)])); // Uint16
Writeln(Format('ServicePackMinorVersion %d', [VarToInteger(FWbemObject.ServicePackMinorVersion)])); // Uint16
Writeln(Format('SizeStoredInPagingFiles %d', [VarToInteger(FWbemObject.SizeStoredInPagingFiles)])); // Uint64
Writeln(Format('Status %s', [VarToString(FWbemObject.Status)])); // String
Writeln(Format('SuiteMask %d', [Integer(FWbemObject.SuiteMask)])); // Uint32
Writeln(Format('SystemDevice %s', [VarToString(FWbemObject.SystemDevice)])); // String
Writeln(Format('SystemDirectory %s', [VarToString(FWbemObject.SystemDirectory)])); // String
Writeln(Format('SystemDrive %s', [VarToString(FWbemObject.SystemDrive)])); // String
Writeln(Format('TotalSwapSpaceSize %d', [StrToIntDef(VarToStr(FWbemObject.TotalSwapSpaceSize), 0)])); // Uint64
Writeln(Format('TotalVirtualMemorySize %d', [VarToInteger(FWbemObject.TotalVirtualMemorySize)])); // Uint64
Writeln(Format('TotalVisibleMemorySize %d', [VarToInteger(FWbemObject.TotalVisibleMemorySize)])); // Uint64
Writeln(Format('Version %s', [VarToString(FWbemObject.Version)])); // String
Writeln(Format('WindowsDirectory %s', [VarToString(FWbemObject.WindowsDirectory)])); // String
Writeln('');
FWbemObject := Unassigned;
end;
end;
begin
try
CoInitialize(nil);
try
GetWin32_OperatingSystemInfo;
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