Microsoft KB Archive/304294

= SAMPLE: Programmatically Install Drivers for Non-PNP Modems on Windows 2000 =

Article ID: 304294

Article Last Modified on 2/12/2007

-

APPLIES TO


 * Microsoft Win32 Device Driver Kit for Windows 2000, when used with:
 * Microsoft Windows 2000 Standard Edition

-



This article was previously published under Q304294



SUMMARY
The sample program that is provided through this article can be used to programmatically install a driver for a legacy nonplug-and-play modem on Windows 2000. This sample is a modified version of the &quot;Install&quot; sample included in the Windows 2000 DDK (Src\General\Setup\Install).



MORE INFORMATION
The following file is available for download from the Microsoft Download Center:

Download Modem.exe now

Release Date: AUG-03-2001

For additional information about how to download Microsoft Support files, click the following article number to view the article in the Microsoft Knowledge Base:

119591 How to Obtain Microsoft Support Files from Online Services

Microsoft scanned this file for viruses. Microsoft used the most current virus-detection software that was available on the date that the file was posted. The file is stored on security-enhanced servers that help to prevent any unauthorized changes to the file. Modem.exe contains the following files:

Build the Sample

 * 1) Download and run Modem.exe to extract the files.
 * 2) To build this sample, select the free or checked build environment and run the build from the directory where you have extracted the files in step 1. This sample links with Newdev.lib, which is present in the DDK library directories. Once built, this sample produces MdmInst.exe.NOTE: If the user requires a program that has no console window, the Sources file can be changed from &quot;UMTYPE=console&quot; to &quot;UMTYPE=windows&quot;.

After the application validates the command line arguments, it uses the port name supplied by the user to call the PortExists function. If the port name is not valid, the application exits. If the port name is valid, the application validates the .inf file and tries to see if the driver for the device that is being installed has already been installed. To do so, it checks whether a devnode for that device already exists. If so, the application updates the driver with the current supplied driver by using UpdateDriverForPlugAndPlayDevices. If the devnode is not already present, the application calls InstallRootEnumeratedDriver(...), which creates a devnode and registers it. The application adds an &quot;&quot;AttachedTo&quot; = COMx&quot; entry for the port to which the modem is being attached, such as

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Class\{4D36E96D-E325-11CE-BFC1-08002BE10318}\000n

“AttachedTo&quot; = REG_SZ : COMx

where 000 represents the instance of a installed modem (for example, 0000,0001...) and n represents a number between 1 and 255.

The application then calls UpdateDriverForPlugAndPlayDevices to attach a driver for the newly created devnode.

Additional query words: modem

Keywords: kbfile KB304294

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.