You have to iterate the result set:
var
Query: string;
WbemLocator, WbemServices, WbemObjectSet: Variant;
Printer: Variant;
I: Integer;
begin
WbemLocator := CreateOleObject('WbemScripting.SWbemLocator');
WbemServices := WbemLocator.ConnectServer('.', 'root\CIMV2');
Query := 'SELECT Name FROM Win32_Printer';
WbemObjectSet := WbemServices.ExecQuery(Query);
if not VarIsNull(WbemObjectSet) and (WbemObjectSet.Count > 0) then
begin
for I := 0 to WbemObjectSet.Count - 1 do
begin
Printer := WbemObjectSet.ItemIndex(I);
if not VarIsNull(Printer) then
begin
Log(Printer.Name);
end;
end;
end;
end;
The code requires Unicode version of Inno Setup (the only version as of Inno Setup 6) for a better Variant
support.
Actually, you can see this code in the same question, where you took the WbemQuery
from:
Is there a way to read the system's information in Inno Setup
Note how the Win32_NetworkAdapterConfiguration
is iterated there.