是否有针对后Delphi 2007的WmiSet的替换或更新?

时间:2011-03-02 17:15:47

标签: delphi wmi wmi-query

我们目前使用Online Admin中的WmiSet来运行Wmi查询并查询远程计算机上的注册表设置。

问题是它只支持Delphi直到RAD Studio 2007.

我们目前正在升级到Delphi XE,需要知道是否有人知道 - 或者有 - 更新版本的WmiSet组件或类似内容。

我们已尝试与供应商联系,但到目前为止,我们的任何查询都没有任何回复。

2 个答案:

答案 0 :(得分:7)

Pieter,前段时间我启动了一个名为Delphi Wmi Class Generator的项目,这个项目创建了完整的文档Object Pascal类(与delphi 7到XE兼容)来访问WMI。

检查此代码,该代码使用TWin32_BIOS类(由应用程序创建)来访问 远程机器中的Win32_BIOS wmi类。

uses
  SysUtils,
  uWmiDelphiClass in '..\..\uWmiDelphiClass.pas',
  uWin32_BIOS in '..\..\root_CIMV2\uWin32_BIOS.pas';

var
  RemoteBiosInfo : TWin32_BIOS;
  i              : integer;
begin
   try
     RemoteBiosInfo:=TWin32_BIOS.Create(False);
     try

       RemoteBiosInfo.WmiServer:='192.168.217.128';
       RemoteBiosInfo.WmiUser  :='Administrator';
       RemoteBiosInfo.WmiPass  :='password'; 
       RemoteBiosInfo.LoadWmiData;

       if RemoteBiosInfo.WmiConnected then  
       begin
         Writeln('Serial Number       '+RemoteBiosInfo.SerialNumber);
         Writeln('BuildNumber         '+RemoteBiosInfo.BuildNumber);
         if RemoteBiosInfo.BIOSVersion.Count>0 then
         Writeln('Version             '+RemoteBiosInfo.BIOSVersion[0]);
         Writeln('Identification Code '+RemoteBiosInfo.IdentificationCode);
         Writeln('Manufacturer        '+RemoteBiosInfo.Manufacturer);
         Writeln('SoftwareElementID   '+RemoteBiosInfo.SoftwareElementID);
         Writeln('Release Date        '+DateToStr(RemoteBiosInfo.ReleaseDate));
         Writeln('Install Date        '+DateToStr(RemoteBiosInfo.InstallDate));
         Writeln('Target S.O          '+GetTargetOperatingSystemAsString(RemoteBiosInfo.TargetOperatingSystem));
         Writeln('Soft. element state '+GetSoftwareElementStateAsString(RemoteBiosInfo.SoftwareElementState));

         Writeln('');
         Writeln('Bios Characteristics');
         Writeln('--------------------'); 
         for i:=Low(RemoteBiosInfo.BiosCharacteristics)  to High(RemoteBiosInfo.BiosCharacteristics) do
          Writeln(GetBiosCharacteristicsAsString(RemoteBiosInfo.BiosCharacteristics[i]));
       end
       else
       Writeln('No connected');
     finally
      RemoteBiosInfo.Free;
     end;
   except
    on E:Exception do
     Writeln(E.Classname, ': ', E.Message);
   end;

 Readln;
end.

答案 1 :(得分:2)

将WMISet库转换为Unicode Delphi并不太难。我已经完成了对Delphi 2009和2010的转换,编译器指向那些需要更改的代码行。如果我找到时间,我会在原始代码和UniCode Delphi更改的代码之间准备一个“diff”并上传它。

此致 奥拉夫