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

x
?
Solved

Installed Modems

Posted on 1999-07-20
11
Medium Priority
?
257 Views
Last Modified: 2010-04-06
how can I get a TStringList of modems wich are installed
on the computer...???
0
Comment
Question by:Smilly
[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
  • 6
  • 4
11 Comments
 
LVL 1

Author Comment

by:Smilly
ID: 1389845
Edited text of question.
0
 
LVL 2

Expert Comment

by:mahara
ID: 1389846
you can make use of RASAPI32.DLL, or RNAPH.DLL for versions of Win95 before OSR2. the function is EnumDevices, and the delphi translations of the API are available anywhere.

Well, the answer is not complete 'cas I cannot supply a sample, but I will do it as soon as possible. I can send you the API header file to use as well, so you'll find more then what you need.

although it's better to communicate here (for common use of information) i'll give my e-mail : devrim@insaat.org

0
 
LVL 1

Author Comment

by:Smilly
ID: 1389847
Is there really No one why has an answer to this one.

0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 15

Expert Comment

by:simonet
ID: 1389848
I can answer this one. Just give me some time to find the code.

Alex
0
 
LVL 1

Author Comment

by:Smilly
ID: 1389849
Hi Alex,
That would be nice....
I have found some source wich I can't get to work...

One wich look in

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Unimodem\DeviceSpecific

I have a modem installed, but I don't have this key
in my registry.

And the other looks in

HKEY_LOCAL_MACHINE\Enum\ISAPNP\*

and checks all the keys to see if there is one named
class with a string value 'modem'. And this doesn't work, becouse I haven't a class key with a value 'modem' in that place....

The only place I can see any class key with a value 'modem'
is in HKEY_LOCAL_MACHINE\Enum\Root\MDMGEN\COM2 but is
this the best way to find the modems..... To look in
HKEY_LOCAL_MACHINE\Enum\Root\MDMGEN\    ??????




0
 
LVL 15

Expert Comment

by:simonet
ID: 1389850
Smilly, here's some code I found which does what you want.

Just another quick note: depending on the specific environment and purpose of your applications, there are better ways of detecting installed modems, like going through the list of RAS devices, TAPI devices, etc. The code above lists modems for general purposes, so it's not restricted to any special usage/environment/OS.

Enjoy it.

Yours,

Alex

*********************** follows code

unit main;

interface

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

type
  TMainForm = class(TForm)
    ModemList: TListView;
    Splitter: TSplitter;
    Panel1: TPanel;
    DataList: TListView;
    procedure SplitterMoved(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure ModemListChange(Sender: TObject; Item: TListItem;
      Change: TItemChange);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
  private
    { Private declarations }
  public
    Reg:TRegistry;
    Running:Boolean;
  end;

var
  MainForm: TMainForm;

implementation

{$R *.DFM}



procedure TMainForm.SplitterMoved(Sender: TObject);
begin
     ModemList.Columns[1].Width:=
       ModemList.Width-ModemList.Columns[0].Width-4;
     DataList.Columns[1].Width:=
       DataList.Width-DataList.Columns[0].Width-4;
end;

procedure TMainForm.FormCreate(Sender: TObject);
var SubKeyList:TStringList; i:integer; Modem:TListItem;
begin
    Reg:=TRegistry.Create;
    Reg.RootKey:=HKEY_LOCAL_MACHINE;
    if Reg.OpenKey('System\CurrentControlSet\Services\Class\Modem',False) then
      if Reg.HasSubKeys then
      begin

        //******************************
        //enumerating modems
        SubKeyList:=TStringList.Create;
        Reg.GetKeyNames(SubKeyList);
        for i:=0 to SubKeyList.Count-1 do
        begin
          Modem:=ModemList.Items.Add;
          Modem.Caption:=SubKeyList.Strings[i];
        end;
        Reg.CloseKey;

        //******************************
        //getting the driver description
        for i:=0 to SubKeyList.Count-1 do
        begin
          Reg.OpenKey('System\CurrentControlSet\Services\Class\Modem\' +
                      ModemList.Items.Item[i].Caption ,False);
          ModemList.Items.Item[i].SubItems.Add(reg.ReadString('DriverDesc'));
          Reg.CloseKey;
        end;

        ModemList.Items.Item[0].Selected:=True;
        Subkeylist.free;
      end else Reg.CloseKey
    else ShowMessage('No modem found!');
    Running:=True;
end;

procedure TMainForm.ModemListChange(Sender: TObject; Item: TListItem;
  Change: TItemChange);
var i:integer; ValList:TStringList; Data:TListItem;
    DataType:TRegDataType;
begin
     if (Change<>ctState) or not Running then Exit;
     
     DataList.Items.Clear;
     Reg.OpenKey('System\CurrentControlSet\Services\Class\Modem\' +
                  Item.Caption,false);
     ValList:=TStringList.Create;
     Reg.GetValueNames(ValList);
     for i:=0 to ValList.Count-1 do
     begin
          Data:=DataList.Items.Add;
          Data.Caption:=ValList.Strings[i];
          DataType:=Reg.GetDataType(ValList.Strings[i]);
          case DataType of
            rdUnknown:
               DataList.Items.Item[i].SubItems.Add(
                       '(Custom data type)');
            rdString,rdExpandString:
               DataList.Items.Item[i].SubItems.Add(
                        reg.ReadString(ValList.Strings[i]));
            rdInteger:
               DataList.Items.Item[i].SubItems.Add(
                        IntToStr(reg.ReadInteger(ValList.Strings[i])))
            else
               DataList.Items.Item[i].SubItems.Add(
                       '(Binary data type)');
          end;

     end;
     Reg.CloseKey;
     ValList.Free;
     Running:=True;
end;

procedure TMainForm.FormClose(Sender: TObject; var Action: TCloseAction);
begin
     Running:=False;
     reg.free;
end;

end.

0
 
LVL 1

Author Comment

by:Smilly
ID: 1389851
Hi Alex,
That's not a very good way for detecting modems,
becouse, if you have modems wich are uninstalled then
they still is showing in HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\Class\Modem\

And I only wants the modems wich are installed.....
What about your second solution 'going through the list of RAS devices, TAPI devices' how do I do that....????
0
 
LVL 15

Expert Comment

by:simonet
ID: 1389852
AS I said, that's for very specific needs.

Before I give you the answer, let me ask you: what do you want to do with the list of installed modems?

Alex
0
 
LVL 1

Author Comment

by:Smilly
ID: 1389853
I have to set up a dialup networking, where the user can
select what modem he/she want to use....


0
 
LVL 15

Accepted Solution

by:
simonet earned 400 total points
ID: 1389854
You should have said that before!

Ok, for that you'll need to use RAS (definitely), and there's a big difference on how it works on NT and Win95. Everything you need is explained in the Win32 SDK help files that come with Delphi 2/3/4/5.

However, I've uploaded a demo application to my site that covers all aspects of RAS (the Dial Up networking is a subset of RAS, but the calls are the same, and are on RASAPI32.DLL). The sample projects includes the best translation of the RAS header for Delphi I know of, and you'll surely need it. It also covers stuff like creation of DUN connections, calling them at runtime, etc.

What you want to achieve is not simply enumerating the local modems, but devices that are RAS-capable, and that includes cable-modems, ISDN devices, cellular modems, etc. The all fall in the category of RAS-capable devices and that's defined by Windows when the device is installed. There's also much more in creating DUN/RAS connections than only the modem: user, password, servers, protocols, etc. The sample project covers it all.

you can download this sample application from:
http://www.bhnet.com.br/~simonet/extras/dialup.zip

Yours,

Alex
Athena's Place: http://www.bhnet.com.br/~simonet


0
 
LVL 1

Author Comment

by:Smilly
ID: 1389855
Thanks Alex....
That was just what I needed.......
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
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…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
Suggested Courses

664 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