si0347429
asked on
Modems in the Registry
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 ...
ASKER
How do I test if it´s connected ???
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
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
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
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...
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...
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/PC I/...../
(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
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/PC
(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
ASKER
I made a test that when I put a modem it adds another in the HKEY_LOCAL_MACHINE/Enum/PC I/...../. 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
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-s tring 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(Seri al : 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_L OCAL_MACHI NE;
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
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-
function .DoesSerialExistInReg(Seri
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_L
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
Did the solution help you?
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