Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2010-11-24
7
Medium Priority
?
847 Views
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?

0
Comment
Question by:byungho
[X]
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
7 Comments
 
LVL 32

Expert Comment

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

procedure TForm3.Button1Click(Sender: TObject);
 var
   Locator:  ISWbemLocator;
   Services: ISWbemServices;
   ObjSet:   ISWbemObjectSet;
   SObject:  ISWbemObject;
   PropSet:  ISWbemPropertySet;
   SProp:    ISWbemProperty;
   sValue:   String;
   Enum:     IEnumVariant;
   Value:    Cardinal;
   TempObj:  OleVariant;
 begin
   Memo1.Lines.Clear;
   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
   begin
     SObject:= IUnknown(tempObj) as SWBemObject;
     PropSet := SObject.Properties_;
     SProp:= PropSet.Item('DeviceID',0);
     sValue:= SProp.Get_Value;
     Memo1.Lines.Add(sValue);
   end;
 end;
0
 
LVL 24

Expert Comment

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

Author Comment

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

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

0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 25

Accepted Solution

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

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

Open in new window

0
 

Author Comment

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

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

Expert Comment

by:epasquier
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
0
 

Author Comment

by:byungho
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.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
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…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

719 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