How can I find serial port(SUNIX PCI Serial I/O Card)

Posted on 2010-11-24
Last Modified: 2013-11-05
I'm using WMI to list serial port (com1~ ...)

Dev Environment: Vista + Delphi2009
Run Environment: Win7 (with pci card)

Here is wmi query:
SELECT DeviceID,Description FROM Win32_SerialPort

But it list only default COM1, not work for SUNIX pci serial i/o card. (COM3~COM10)

Windows device manager show correctly serial ports like this:
COM1 (default in bios)
SUNIX COM Port(COM3 - 10)

any idea?

Question by:byungho
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
LVL 32

Expert Comment

by:Ephraim Wangoya
ID: 34211062
Have you tried this solution from sergeworks

procedure TForm3.Button1Click(Sender: TObject);
   Locator:  ISWbemLocator;
   Services: ISWbemServices;
   ObjSet:   ISWbemObjectSet;
   SObject:  ISWbemObject;
   PropSet:  ISWbemPropertySet;
   SProp:    ISWbemProperty;
   sValue:   String;
   Enum:     IEnumVariant;
   Value:    Cardinal;
   TempObj:  OleVariant;
   Locator:= CoSWbemLocator.Create;
   Services:=  Locator.ConnectServer('.', 'root\cimv2', '', '', '','', 0, nil);
   ObjSet:= Services.InstancesOf('Win32_SerialPort', wbemFlagReturnWhenComplete, nil);
   Enum:= (ObjSet._NewEnum) as IEnumVariant;
   while (Enum.Next(1, tempObj, Value) = S_OK) do
     SObject:= IUnknown(tempObj) as SWBemObject;
     PropSet := SObject.Properties_;
     SProp:= PropSet.Item('DeviceID',0);
     sValue:= SProp.Get_Value;
LVL 24

Expert Comment

ID: 34211066
Is the device enabled in the Device Manager (ports) ?

Author Comment

ID: 34211158
to ewangoya//  It's same result.

to jimyX// Yes, I connected one port COM4.

[Live Webinar] The Cloud Skills Gap

As Cloud technologies come of age, business leaders grapple with the impact it has on their team's skills and the gap associated with the use of a cloud platform.

Join experts from 451 Research and Concerto Cloud Services on July 27th where we will examine fact and fiction.

LVL 25

Accepted Solution

epasquier earned 125 total points
ID: 34211743
try this
procedure ScanDOSDevices(Var List:TStringList);
  Str: string;
  Size, i, j: dword;
 if Not Assigned(List) then List:=TStringList.Create Else List.Clear;
 Setlength(Str, i) ;
 Size := QueryDosDevice(nil, @Str[1], i) ;
 While (Size=0) And (GetLastError=ERROR_INSUFFICIENT_BUFFER) do
   Setlength(Str, i) ;
   Size := QueryDosDevice(nil, @Str[1], i) ;
 for j := 1 to Size-1 do if Str[j] = #0 then Str[j] := ',';
 List.CommaText := Str;

procedure ScanCOMDevices(Var List:TStringList);
 for i := List.Count - 1 downto 0 do if Copy(List[i],1,3)<>'COM' then List.Delete(i);

Open in new window


Author Comment

ID: 34211950
to epasquier// It works,  thank you.

Is it right method to this? I want prefer to use WMI.
LVL 25

Expert Comment

ID: 34212184
WMI is just an extensive layer to get hardware information , among other things.
but it is heavy to use and sometimes it does not return what we need.

The code above is based on Windows API to get all devices as enumerated in the hardware manager. I don't know if it is the only one, but that is one that works on all windows systems and quickly.
It is up to you then to decide if it is "the right" method

Author Comment

ID: 34212306
to epasquier//

Yes! It is "right method" to list serial port names.

If available by wmi to detail information, it's perfact for me.

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Suggested Courses
Course of the Month5 days, 23 hours left to enroll

627 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question