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
|
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ActiveX, Comobj;
type
TForm1 = class(TForm)
Memo1: TMemo;
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Déclarations privées }
procedure GetWin32_NetworkConnectionInfo;
public
{ Déclarations publiques }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
//-----------------------------------------------------------------------------------------------------
// This code was generated by the Wmi Delphi Code Creator (WDCC) Version 1.8.5.0
// <a href="http://code.google.com/p/wmi-delphi-code-creator/" target="_blank">http://code.google.com/p/wmi-delphi-code-creator/</a>
// Blog <a href="http://theroadtodelphi.wordpress.com/wmi-delphi-code-creator/" target="_blank">http://theroadtodelphi.wordpress.com...-code-creator/</a>
// Author Rodrigo Ruz V. (RRUZ) Copyright (C) 2011-2014
//-----------------------------------------------------------------------------------------------------
//
// 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.
//
//----------------------------------------------------------------------------------------------------
// La classe Win32_NetworkConnection représente une connexion réseau active dans
// un environnement Win32.
procedure TForm1.GetWin32_NetworkConnectionInfo;
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_NetworkConnection','WQL',wbemFlagForwardOnly);
oEnum := IUnknown(FWbemObjectSet._NewEnum) as IEnumVariant;
while oEnum.Next(1, FWbemObject, iValue) = 0 do
begin
memo1.lines.add(Format('AccessMask %d',[Integer(FWbemObject.AccessMask)]));// Uint32
memo1.lines.add(Format('Caption %s',[String(FWbemObject.Caption)]));// String
memo1.lines.add(Format('Comment %s',[String(FWbemObject.Comment)]));// String
memo1.lines.add(Format('ConnectionState %s',[String(FWbemObject.ConnectionState)]));// String
memo1.lines.add(Format('ConnectionType %s',[String(FWbemObject.ConnectionType)]));// String
memo1.lines.add(Format('Description %s',[String(FWbemObject.Description)]));// String
memo1.lines.add(Format('DisplayType %s',[String(FWbemObject.DisplayType)]));// String
memo1.lines.add(Format('InstallDate %s',[String(FWbemObject.InstallDate)]));// Datetime
memo1.lines.add(Format('LocalName %s',[String(FWbemObject.LocalName)]));// String
memo1.lines.add(Format('Name %s',[String(FWbemObject.Name)]));// String
memo1.lines.add(Format('Persistent %s',[String(FWbemObject.Persistent)]));// Boolean
memo1.lines.add(Format('ProviderName %s',[String(FWbemObject.ProviderName)]));// String
memo1.lines.add(Format('RemoteName %s',[String(FWbemObject.RemoteName)]));// String
memo1.lines.add(Format('RemotePath %s',[String(FWbemObject.RemotePath)]));// String
memo1.lines.add(Format('ResourceType %s',[String(FWbemObject.ResourceType)]));// String
memo1.lines.add(Format('Status %s',[String(FWbemObject.Status)]));// String
memo1.lines.add(Format('UserName %s',[String(FWbemObject.UserName)]));// String
memo1.lines.add('');
FWbemObject:=Unassigned;
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
GetWin32_NetworkConnectionInfo;
end;
end. |
Partager