Ver Mensaje Individual
  #1  
Antiguo 06-04-2013
madiazg madiazg is offline
Miembro
 
Registrado: sep 2005
Ubicación: Canarias
Posts: 120
Reputación: 19
madiazg Va por buen camino
Error utilizando WMI

Buenos días,
he intentado utilizar el código que aparece en el artículo All about WiFi Networks and WiFi Adapters using the WMI and Delphi pero al ejecutar el procedimiento Current Wifi NetWork me da un error indicándome "clase no válida".

Project raised exception class EOleException with message "Clase no válida"

en la línea
Código:
FWbemObjectSet:= FWMIService.ExecQuery('SELECT * FROM WiFi_AdapterAssociationInfo','WQL',wbemFlagForwardOnly);
El código completo es el siguiente:
Código:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls,
  ComObj, ActiveX, Variants, XPMan;

type
  TForm1 = class(TForm)
    Button1: TButton;
    Memo1: TMemo;
    XPManifest1: TXPManifest;
    Button2: TButton;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure  GetWiFi_AdapterAssociationInfo; //Current Wifi NetWork
const
  WbemUser            ='';
  WbemPassword        ='';
  WbemComputer        ='localhost';
  wbemFlagForwardOnly = $00000020;
var
  FSWbemLocator : OLEVariant;
  FWMIService   : OLEVariant;
  FWbemObjectSet: OLEVariant;
  FWbemObject   : OLEVariant;
  oEnum         : IEnumvariant;
  iValue        : LongWord;
begin;
  Form1.Memo1.Clear;
  FSWbemLocator := CreateOleObject('WbemScripting.SWbemLocator');
  FWMIService   := FSWbemLocator.ConnectServer(WbemComputer, 'root\CIMV2', WbemUser, WbemPassword);
  FWbemObjectSet:= FWMIService.ExecQuery('SELECT * FROM WiFi_AdapterAssociationInfo','WQL',wbemFlagForwardOnly);
  oEnum         := IUnknown(FWbemObjectSet._NewEnum) as IEnumVariant;
  while oEnum.Next(1, FWbemObject, iValue) = 0 do
  begin
    Form1.Memo1.Lines.Add(Format('Associated         %s',[FWbemObject.Associated]));// Boolean
    Form1.Memo1.Lines.Add(Format('AuthenAlgorithm    %s',[FWbemObject.AuthenAlgorithm]));// String
    Form1.Memo1.Lines.Add(Format('AuthenEnabled      %s',[FWbemObject.AuthenEnabled]));// Boolean
    Form1.Memo1.Lines.Add(Format('AuthenMode         %s',[FWbemObject.AuthenMode]));// String
    Form1.Memo1.Lines.Add(Format('Caption            %s',[FWbemObject.Caption]));// String
    Form1.Memo1.Lines.Add(Format('Channel            %s',[FWbemObject.Channel]));// String
    Form1.Memo1.Lines.Add(Format('Description        %s',[FWbemObject.Description]));// String
    Form1.Memo1.Lines.Add(Format('Encryption         %s',[FWbemObject.Encryption]));// String
    Form1.Memo1.Lines.Add(Format('OpMode             %s',[FWbemObject.OpMode]));// String
    Form1.Memo1.Lines.Add(Format('Profile            %s',[FWbemObject.Profile]));// String
    Form1.Memo1.Lines.Add(Format('Rate               %s',[FWbemObject.Rate]));// String
    Form1.Memo1.Lines.Add(Format('SettingID          %s',[FWbemObject.SettingID]));// String
    Form1.Memo1.Lines.Add(Format('SSID               %s',[FWbemObject.SSID]));// String
    FWbemObject:=Unassigned;
  end;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
  GetWiFi_AdapterAssociationInfo;
end;

end.
Utilizo Windows XP y Windows 7 y programo en Turbopascal.

¿Alguien puede ayudarme?

Saludos...
Responder Con Cita