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

This article was previously published under Q304294
This article has been archived. It is offered "as is" and will no longer be updated.
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 "Install" sample included in the Windows 2000 DDK (Src\General\Setup\Install).
The following file is available for download from the Microsoft Download Center:
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:
Mdminst.cSource file
MakefileStandard Windows NT makefile
SourcesDependency and include file

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 "UMTYPE=console" to "UMTYPE=windows".
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 ""AttachedTo" = COMx" entry for the port to which the modem is being attached, such as
“AttachedTo" = 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.

Article ID: 304294 - Last Review: 02/27/2014 21:09:39 - Revision: 4.3

  • Microsoft Win32 Device Driver Kit for Windows 2000
  • kbnosurvey kbarchive kbfile KB304294