Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

Detecting and Installing Modem and RAS, Dial-up Network.

0.00/5 (No votes)
15 May 2002 4  
Detecting whether Modem and Dial-up Networking is installed in your system. If not, installing them programatically.

Introduction

This article discusses in detail how to detect whether any modem is present in your system. If not how to start the installation of the Modem programatically. It also detects whether RAS,DUN is already installed and if not how to start the installation of the same programatically.

Detecting and Installing Modem

To detect whether modem is present in your system, we have to check out the registry. If your OS version is Platform Win32 NT, ie, Windows NT or XP or 2000, then we have to open the key

  HKEY_LOCAL_MACHINE,
    "SYSTEM\\CurrentControlSet\\Control\\Class\\"
    "{4D36E96D-E325-11CE-BFC1-08002BE10318}" 
else if your OS version is Platform Win32 Windows, i.e., 9x or ME, then we have to open the key
  HKEY_LOCAL_MACHINE,"System\\CurrentControlSet\\Services\\Class\\Modem" 
and count the number of sub-keys under it. If any modem is present then the count will be greater than or equal to 1. If it is less than 1 then it means there is no modem present in the system.

To install the modem, just execute the Control Panel applet for Modem, and give the commannd line arguement as add, ie,

 "rundll32.exe shell32.dll,Control_RunDLL Modem.cpl,,add",1 

Detecting and Installing RAS or DUN

To detect whether RAS is installed in OS version Platform Win32 NT, try opening the registry key

 HKEY_LOCAL_MACHINE,"SYSTEM\\CurrentControlSet\\Services\\RemoteAccess" 
if its successful, then RAS is already installed in your system. If its unsuccessful, then you can start the installation of the same by executing
 rasphone.exe 

To detect whether Dial-up Networking is installed in OS version Platform Win32 Windows, except Windows ME, try opening the registry key

 HKEY_LOCAL_MACHINE,
    "System\\CurrentControlSet\\Services\\RemoteAccess\\NetworkProvider" 
if its successful, then Dial-up is installed for Windows ME, open the registry key
 HKEY_LOCAL_MACHINE,"SOFTWARE\\Microsoft\\Windows\\"
    "CurrentVersion\\Setup\\OptionalComponents\\RNA\\" 
and query the value
 "Installed" 
if the value is 1 then Dial-up is installed.

Otherwise, install the same by executing

 "rundll.exe setupx.dll,InstallHinfSection rna 0 rna.inf" 

Conclusion

This is tested OK on all Windows OS. If you find any odd thing kindly let me know.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here