Solved

Modems in the Registry

Posted on 2003-12-02
9
379 Views
Last Modified: 2010-04-06
I asked a question before in how to get the modems installed on the computer. They answered me on the registry. BUT, if I installed 3 modems on my computer it shows me 3. That´s right, but when I take one off, it still stays on the registry. Then it will also give me 3 modems installed and not 2. This test I made it in Windows 2000. How do I solve this problem ? Is there a subkey in the modem´s key that tell me which one is actually installed ( being used) ? Or something ...
0
Comment
Question by:si0347429
  • 6
  • 3
9 Comments
 
LVL 1

Expert Comment

by:Binsky
ID: 9857680
I remember that question, or one like it...

The answer to that question was, that it isn't possible by just looking at the registry. (But I'm not sure myself though, I haven't tried it personally)

The solution provided was adding a flag yourself, which should tell you if a modem's connected, or at least reachable. So you could add a subkey yourself, connected to a modem_copnnection testing procedure or something like that.

Hope this helped,

Binsky
0
 

Author Comment

by:si0347429
ID: 9860499
How do I test if it´s connected ???
0
 
LVL 1

Expert Comment

by:Binsky
ID: 9866011
Hi,

That's a good question! I must admit I hadn't looked into that yet... But, as I am currently working on a program that needs modem connectivity, I've ran a quick search on this...

What I've found so far is that it is possible to try to connect through the comm port the modem is connected to...In any basic serial port unit there will be a commportpresent procedure, try that for basic connection, if that works, try sending something to the modem, and test for correct reply (?)

I'll have time for more research tomorrow, or maybe later today...I'll probably be able to give you a clearer answer then, if you need it...

I read somewhere that if "AT" is entered in Hyperterm, the unit should respond with  "OK".

It should be possible to do the hyperterm stuff via the serial port.

Binsky
0
 
LVL 1

Accepted Solution

by:
Binsky earned 250 total points
ID: 9866050
I couldn't help myself, and searched some more...On a Borland page I've found the code for modem connection testing :

Note that this doesn't tell you which modem it is connecting to, you'd still need to figure that part out...It does tell you how to read the modem's status, and I guess that would do the trick!

Question:
How can I get the modem status under Win32?

Answer:
The following example demonstrates retrieving the current state
of the modem control-register values under Win32.

Example:
procedure TForm1.Button1Click(Sender: TObject);
var
  CommPort : string;
  hCommFile : THandle;
  ModemStat : DWord;
begin
  CommPort := 'COM2';

 {Open the comm port}
  hCommFile := CreateFile(PChar(CommPort),
                          GENERIC_READ,
                          0,
                          nil,
                          OPEN_EXISTING,
                          FILE_ATTRIBUTE_NORMAL,
                          0);
  if hCommFile = INVALID_HANDLE_VALUE then
  begin
    ShowMessage('Unable to open '+ CommPort);
    exit;
  end;

 {Get the Modem Status}
  if GetCommModemStatus(hCommFile, ModemStat) <> false then begin
    if ModemStat and MS_CTS_ON <> 0 then
      ShowMessage('The CTS (clear-to-send) is on.');
    if ModemStat and MS_DSR_ON <> 0 then
      ShowMessage('The DSR (data-set-ready) is on.');
    if ModemStat and MS_RING_ON <> 0then
      ShowMessage('The ring indicator is on.');
    if ModemStat and MS_RLSD_ON <> 0 then
      ShowMessage('The RLSD (receive-line-signal-detect) is
on.');
end;

 {Close the comm port}
  CloseHandle(hCommFile);
end;

I found this at : http://www.lars.pl/ftp/Delphi/borland/faq/1444.HTM

0
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 

Author Comment

by:si0347429
ID: 9867614
Hey Binsky,

   The source above worked great. Thanx alot. I know that in the registry it has it´s port number, so i can get i from there. Do you know if there´s a way to know from the registry which modem is active ? Or something...
0
 
LVL 1

Expert Comment

by:Binsky
ID: 9867806
Hi again,

Well, I don't really know about that, but as I've said in my first post, I did find another thread on this, and the expert that solved it said that there wasn't a key that said which modem is active...

But with the code, you could "manually" check the modems in the registry, to see if they're alive, and create your own registry entry to store which modems are alive and which need ignoring.

On my own pc the only reference to my PCI modem was in  
HKEY_LOCAL_MACHINE/Enum/PCI/...../

(But I think you already know where to find the registry item)

As far as I know there isn't a key that says which is active. (That last one is the short answer ;-) )

Binsky
0
 

Author Comment

by:si0347429
ID: 9873387
I made a test that when I put a modem it adds another in the HKEY_LOCAL_MACHINE/Enum/PCI/...../. Then I take it off but it stays there. The only change that made was that the windows took a subkey off named "Control" from the modem that´s not being used. If i could test if this subkey exists. Do you know how ? Thanx for helping me
0
 
LVL 1

Expert Comment

by:Binsky
ID: 9873490
If you know the exact string to search for, you could store that string yourself, and then do a strcomp(S1, S2);

This is a stringcompare function, that'll tell you if the string in the registry is the same as your stored string...(very case sensitive)

For another project I've created a search-the-registry-for-a-specific-string procedure, please note that this will need some tweaking for your specific needs, as I had the advantage that the registry keys I was searching for were numbered, you'd need to "ReadString("Control");" and compare the result from the readstring. (or something like that)


function .DoesSerialExistInReg(Serial : string) : boolean;
var
   MyReg           : TRegistry;
   index           : integer;
   TempIndex       : string;
   RegSerialString : string;
   Max : integer;
begin
   Result := false;
   Myreg := TRegistry.Create;
   with MyReg do
   begin
      Rootkey := HKEY_CURRENT_USER;//HKEY_LOCAL_MACHINE;
      if OpenKey('Insert specific Key here\' , True) then
      begin
        for index := 0 to Max do
        begin
          try
             RegSerialString   := ReadString('Control');                        except
             MessageDlg('There was an error while reading registry values', mtError, [mbOk], 0);
             result := false;
          end; // try..except
          if (Serial = RegSerialString) then
            Result := true;
        end; // for
      CloseKey;
      end; // openkey
   end; // with myreg do
   MyReg.Free;
end;

Binsky
0
 
LVL 1

Expert Comment

by:Binsky
ID: 9963146
Did the solution help you?
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

743 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now