HOWTO: Install Networking Components Programmatically

Last reviewed: July 7, 1997
Article ID: Q169580
The information in this article applies to:
  • Windows 95 Device Driver Kit (DDK), version 4.0

SUMMARY

Many cutting-edge software products require Internet or network access. Therefore, installation applications need to verify that critical networking components are installed, and possibly initiate installation of these components when necessary. Programmatic detection and installation of networking components can be accomplished using a 16-bit protected mode Setup API on Windows 95. This API is documented in DevInst.Doc in the Win95 DDK.

MORE INFORMATION

DevInst.Doc documents the Setup API itself and the parameters for each API call without illuminating any of the implementation details for installing a device. You can download a sample MFC application from the Microsoft Software Library or from the Microsoft OEM/IHV DDK home page at:

   http://www.microsoft.com/support/products/developer/ddk_hardware/

Follow the links to the WinDDK Samples page. The sample is a MSVC 1.52 MFC application. You should not try to install PCMCIA or PCI devices with this application. These devices are installed when they are inserted for the first time or during boot time. The sample makes use of DiCreateDevRegKey:

   RETERR DiCreateDevRegKey( LPDEVICEINFO lpdi,
                             LPHKEY       lphKey,
                             HINF         hInf,
                             LPCSTR       lpszInfSection,
                             int          iFlags )

Create a unique registry key under the class of the associated device.

It returns OK if it has been successful; otherwise, an ERR_DI_xxx error code will be returned. If the return is OK, the lphKey will point to a valid handle to the created key. It is the caller's responsibility to close the returned registry key.

lpdi

  • Pointer to a DEVICE_INFO struct for a device that is being installed.

lphKey
  • Pointer to receive the address of the created registry key handle.

hInf
  • Handle to an opened INF file. hInf and lpszInfSection are rarely used. These would be necessary only if some special information had to be added to the registry when the key is first created.

lpcInfSection
  • Section of the INF file to be executed using the newly-created registry key.

iFlags
  • Indicates which type of registry key to create:

    DIREG_DEV Create a hardware registry key for the device. This is a key that exists in the \\HKLM\\ENUM branch specified by lpdi->lpszRegSubkey. If lpdi->lpszRegSubkey is NULL, then the key will be created in \\HKLM\\ENUM\\ROOT\\lpdi->szClassName.

    DIREG_DRV Create a software, or driver, registry key for the device. This is a key that is in \\HKLM\\System\\CurrentControlSet\\Services\\Class\\ lpdi->szClassName.

The sample will accept several command line arguments:
  • Ipinst [-a[idstring]] [-<h|?>] [-f<logfile>] [-m[d|idstring]] [- p<COM1|COM2>] [-r] [-s] [-v]

    -a[PnP ID String] Install adapter. A PnP ID String can be specified. If no adapter is specified or detected, the user must select one.

    -f<log file name> Specify a log file. If the log file name is NULL, then the default is Ipdetect.txt.

    -<h|?> Display usage information.

    -m[d|Modem PnP String|Unimodem ID String] Install modem. A PnP ID or Unimodem String can be specified. If no modem is specified or detected, the Modem Wizard is invoked.

    -p<COM1|COM2> Attach modem to COM1 or COM2. The default is COM1. This is to be used with the 'm' option to attach the installed modem to the specified port. This is mainly for legacy modems with valid Unimodem ID's.

    -r Install remote networking. This includes RNA, Dial Up Adapter, and related RAS components.

    -s

    Show application. By default, the application runs hidden. The application will show up on the desktop only if the 's', 'h' or '?' options are used.

    -v Emit verbose messages to logfile. The contents of the logfile show up on the document client area when the application is visible.

REFERENCES

DDpr.Hlp, DevInst.Doc, Network.Doc


Keywords : kbsetup kbhowto
Technology : kbMfc
Version : 4.0
Platform : WINDOWS


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: July 7, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.