DWScript 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); for var 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.
Hello Eric!
Can I disable the COM functions in the DWS?
Tony
@Tony The COM connector is only active if you enable it (as are all the other extensions that can break sandboxing, like RTTI).
Ok, thank you!