Hufff... you must import a type library...
Better... use the code of my answer of this question:
http://www.experts-exchang
Main Topics
Browse All TopicsWith this code, I can enumerate the parellel ports.
Im getting the properties Caption and PNPDeviceId but... I want also get the property called 'Capabilities' that is an array of uint16
How can I get these values?
procedure TForm1.Button3Click(Sender
procedure EnumerateParallelPorts(The
var
oCosas,
oCosa : OleVariant;
services : OleVariant;
iTemp : longword;
oEnum : IEnumvariant;
Locator : ISWbemLocator;
begin
Locator := CreateOleObject('WbemScrip
Services := Locator.ConnectServer('.',
oCosas:=Services.ExecQuery
oEnum := IUnknown(oCosas._NewEnum) as IEnumVariant;
//Get name & PNPDeviceId of the ports
while oEnum.Next(1,oCosa,iTemp) = 0 do begin
TheList.Add( Format('Port: %s, DeviceId: %s',[oCosa.Caption,oCosa.P
//There are a property called:
// Capabilities
// Data type: uint16 array
// I want read its values... How? :?
oCosa:=Unassigned;
end;
oCosas := Unassigned;
Services:=Unassigned;
end;
begin
EnumerateParallelPorts(Mem
end;
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Hufff... you must import a type library...
Better... use the code of my answer of this question:
http://www.experts-exchang
Try this:
procedure EnumerateParallelPorts(The
var
oCosas,
A,oCosa : OleVariant;
services : OleVariant;
i,iTemp : longword;
oEnum : IEnumvariant;
Locator : ISWbemLocator;
begin
Locator := CreateOleObject('WbemScrip
Services := Locator.ConnectServer('.',
oCosas:=Services.ExecQuery
oEnum := IUnknown(oCosas._NewEnum) as IEnumVariant;
//Get name & PNPDeviceId of the ports
while oEnum.Next(1,oCosa,iTemp) = 0 do begin
TheList.Add( Format('Port: %s, DeviceId: %s',[oCosa.Caption, oCosa.PNPDeviceId]) );
vArray := oCosa.Capabilities.Value;
if not VarIsNull(vArray) then
for i := VarArrayLowBound(vArray,1)
TheList.Add( Format(' Capabilities[%d]: %s',[i, VarToStr(vArray[i])]));
oCosa:=Unassigned;
end;
oCosas := Unassigned;
Services:=Unassigned;
end;
Hi!
Thanks for your code!
Missing definition for vArray... I suppose that is a OleVariant :?
The code raises an exception in:
vArray:=oCosa.Capabilities
but with this works:
vArray:=oCosa.Capabilities
Finally, this works:
procedure TForm1.Button3Click(Sender
procedure EnumerateParallelPorts(The
var
oCosas,
vArray,
oCosa : OleVariant;
services : OleVariant;
i,iTemp : longword;
oEnum : IEnumvariant;
Locator : ISWbemLocator;
begin
Locator := CreateOleObject('WbemScrip
Services := Locator.ConnectServer('.',
oCosas:=Services.ExecQuery
oEnum := IUnknown(oCosas._NewEnum) as IEnumVariant;
//Get name & PNPDeviceId of the ports
while oEnum.Next(1,oCosa,iTemp) = 0 do begin
TheList.Add( Format('Port: %s, DeviceId: %s',[oCosa.Caption, oCosa.PNPDeviceId]) );
//vArray:=oCosa.Capabiliti
vArray:=oCosa.Capabilities
if not VarIsNull(vArray) then
for i := VarArrayLowBound(vArray,1)
TheList.Add( Format(' Capabilities[%d]: %s',[i, VarToStr(vArray[i])]));
oCosa:=Unassigned;
end;
oCosas := Unassigned;
Services:=Unassigned;
end;
begin
EnumerateParallelPorts(Mem
end;
Sorry, I've declared an "A" variant variable, and after I rename to vArray to better reading.
I've not tested this code, because my NB doesn't have paralel ports.
I use your previous question:
procedure EnumerateNetworkAdapters(T
var
oBindObj : IDispatch;
oNetAdapters,
oNetAdapter, prop,
oWMIService : OleVariant;
i,
iValue : longword;
oEnum,Props : IEnumvariant;
oCtx : IBindCtx;
oMk : IMoniker;
sFileObj : widestring;
begin
sFileObj := 'winmgmts:\\.\root\cimv2';
// Connect to WMI - Emulate API GetObject()
OleCheck(CreateBindCtx(0,o
OleCheck(MkParseDisplayNam
OleCheck(oMk.BindToObject(
oWMIService := oBindObj;
oNetAdapters := oWMIService.ExecQuery('Sel
'Win32_NetworkAdapterConfi
oEnum := IUnknown(oNetAdapters._New
while oEnum.Next(1,oNetAdapter,i
TheList.Add('');
TheList.Add(oNetAdapter.Ca
Props := IUnknown(oNetAdapter.Prope
while Props.Next(1, prop, iValue) = 0 do begin
if Prop.IsArray then begin
if VarIsNull(Prop.Value) then
TheList.Add(' '+prop.Name+'[Array]: Null')
else begin
for i := VarArrayLowBound(Prop.Valu
TheList.Add( Format(' %s[%d]: %s',[VarToStr(prop.Name), i, VarToStr(Prop.Value[i])]))
end;
end else if VarIsNull(Prop.Value) then
TheList.Add(' '+prop.Name+': Null')
else
TheList.Add(' '+prop.Name + ': '+string(Prop.Value));
end;
TheList.Add(oNetAdapter.Ca
end;
oNetAdapters := Unassigned;
oWMIService := Unassigned;
end;
Nah...dont worry... its a personal challenge answering a question & learning about wmi possibilities.
I have write a code for get the parallel ports adresses... this works, but the other part of the question was: get if the port is normal, ecp, epp, etc...
The question, and my code is in:
http://www.experts-exchang
Business Accounts
Answer for Membership
by: ZhaawZPosted on 2005-09-01 at 04:05:01ID: 14800803
Which unit is it? (undeclared identifiers 'IEnumvariant', 'ISWbemLocator', 'CreateOleObject' etc)