Quantcast
Channel: Planet Object Pascal
Viewing all articles
Browse latest Browse all 1725

DelphiTools.info: COM connector spring cleanup

$
0
0

ConnectorsDWScript COM Connector has just received a spring cleanup, as it had grown a bit mouldy over the last years.  The COM Connector optionally gives scripts direct access to ActiveX and COM objects.

As part of the cleanup, it now support IEnumVARIANT and ComVariantArray can now be enumerated as well with “for in“.

In practice it means you can now use it to query WMI information f.i., as an illustration the following code will run a WQL query and print the name of the processor running the system:

const wbemFlagForwardOnly = $00000020;

var locator := CreateOleObject('WbemScripting.SWbemLocator');
var service := locator.ConnectServer('localhost', 'root\CIMV2', '', '');
var objectSet := service.ExecQuery('Select Name from Win32_Processor',
                                   'WQL', wbemFlagForwardOnly);

forvar item in objectSet do
   PrintLn(item.Properties_.Item('Name').Value);

And speaking of WMI, Rodrigo RUZ maintains a lot of useful WMI queries on his The Road To Delphi blog.


Viewing all articles
Browse latest Browse all 1725

Trending Articles