How do I detect the modem's comport?

Hi.

How can I detect on which comport my modem is installed ?

Thnaks.
ranmanorAsked:
Who is Participating?
 
simonetConnect With a Mentor Commented:
HEre you go:


unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  WinSpool, ComCtrls;

type
  TForm1 = class(TForm)
    ListView2: TListView;
    procedure FormCreate(Sender: TObject);
  private
    { Déclarations privées }
  public
    { Déclarations publiques }
    Ports: Array[1..100] of TPortInfo2;
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.FormCreate(Sender: TObject);
Var
  Returned : cardinal;
  Item: TListItem;
  i : cardinal;
begin
  if ( EnumPorts(nil, 2, Pointer(@Ports), Sizeof(Ports), i, Returned) ) then begin
    ListView2.Items.Clear;
    for i:= 1 to Returned do begin
      if ( Pos('COM', Ports[i].pPortName) = 1 ) or ( Pos('LPT', Ports[i].pPortName) = 1 ) then begin
        Item:= ListView2.Items.Add;
        Item.Caption:= Ports[i].pPortName;
        Item.SubItems.Add(Ports[i].pDescription);
        Item.SubItems.Add(Ports[i].pMonitorName);
      end;
    end;
  end;
end;

end.


Yours,

Alex
0
 
ranmanorAuthor Commented:
thanks!
0
All Courses

From novice to tech pro — start learning today.