Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

155 lines
6.4 KiB

  1. <HTML>
  2. <HEAD>
  3. <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=windows-
  4. 1252">
  5. <META NAME="Generator" CONTENT="Microsoft Word 97">
  6. <TITLE>Ports Class Installer
  7. </TITLE>
  8. </HEAD>
  9. <BODY LINK="#0000ff">
  10. <FONT FACE="Verdana" SIZE=5><H2>Ports Class Installer
  11. </H2>
  12. </FONT><FONT FACE="Verdana" SIZE=2>
  13. <P><span style="color:#FF0000;font-size:10pt;font-family:Arial">[This is preliminary
  14. documentation and subject to change.]</span></P>
  15. <H3>SUMMARY</H3></FONT><FONT FACE="Verdana" SIZE=2>
  16. <P>
  17. This sample demonstrates a class installer and property page provider for the
  18. ports class of devices. The ports class is divided into two types of devices,
  19. COM (serial) ports and LPT or ECP (printer) ports. A separate property page is
  20. provided for each type of device. Furthermore, the class installer distinguishes
  21. both types of devices and installs each type of device differently.
  22. </P>
  23. <blockquote>
  24. <b>Note:</b> When using this sample, you need to code whatever is specific to your class. This sample is specific to port class only. Copying and pasting this code without modification may lead to disaster for other classes.
  25. </blockquote>
  26. The sample runs on the x86 platform. It has only been tested in a 32-bit environment.
  27. <p>
  28. <H3>BUILDING THE SAMPLE</H3></FONT><FONT FACE="Verdana"
  29. SIZE=2><P>
  30. Enter the checked or free build environment. Then,
  31. while in the Class Installer sample directory, type <b>build</b>. A successful build produces
  32. the executable <i>pnpports.dll.</i>
  33. <H3>RELEASE NOTES</H3></FONT><FONT FACE="Verdana" SIZE=2><P>
  34. <H3>CODE TOUR</H3>
  35. <H4>File Manifest</H4>
  36. </FONT>
  37. <U><PRE>File&#9;&#9;Description</U>
  38. <I>advandlg.c</I>&#9;Advanced dialog for COM port property page
  39. <I>ports.h</I>&#9; Ports header file
  40. <I>ports.c</I>&#9; Class Installer for the Ports clas
  41. <I>pp.c</I>&#9; Property Page Provider for COM ports
  42. <I>pp.h</I>&#9; Definitions for pp.c
  43. <I>pp_lpt.c</I>&#9;Property Page Provider for LPT and ECP ports
  44. <I>pp_lpt.h</I>&#9;Definitions for pp_lpt.c
  45. <I>util.c</I>&#9; Utility functions
  46. <I>ports.rc</I>&#9;Resources
  47. <I>ports.rc2</I>&#9;Resources
  48. <I>pnpports.def</I>&#9;Exports file
  49. <I>ports.htm</I>&#9;This file
  50. <I>Sources</I>&#9; needed to build
  51. <I>Makefile</I>&#9;needed to build
  52. </pre>
  53. <h4><font face="Verdana">Programming Tour</font></h4>
  54. <font face="Verdana" size="2">
  55. <p>This programming tour shows the specifics of the class installer and how the property
  56. pages are added and initialized.</p>
  57. <h5><font face="Verdana">The Class Installer</font></h5>
  58. <p>When the device is being installed, the class installer must first determine whether a COM or LPT port is being installed. The class installer
  59. relies on the .inf file that installed the device to write this value into the
  60. registry. The .inf must include an AddReg directive which writes a binary value
  61. named <b>PortSubClass</b> in the driver key for the device instance. Please see
  62. the sections [LptPort.AddReg], [EcpPort.AddReg], and [ComPort.AddReg] in
  63. <I>msports.inf</I>.</p>
  64. <p>The class installer handles ths following DIF codes:</p>
  65. <font FACE="Verdana" SIZE="2">
  66. <ul>
  67. <li>DIF_INSTALLDEVICE</li>
  68. <li>DIF_REMOVE</li>
  69. </ul>
  70. </font>
  71. <p>The handling DIF_INSTALLDEVICE is specific to the device type. This example
  72. demonstrates how to handle DIF_INSTALLDEVICE for COM ports. While the Ports
  73. Class installer shipped with the system also handles LPT ports in
  74. DIF_INSTALLDEVICE, this sample just informs Setup to perform the default
  75. installation.</p>
  76. <p>The primary purpose of the COM ports class installer is to assign a port name,
  77. e.g. COM1, to the device and to create a friendly name for the device that
  78. includes the port name. Providing a unique name to the port can prove to be
  79. difficult; with that in mind, a COM name database was created. The API for the
  80. database resides in <I>msports.dll</I> (which <I>pnpports.dll</I> links against). The
  81. database provides concurrent access to the list of names that have already
  82. been claimed by other ports and modems.</p>
  83. <p>The COM port class installer assigns a name to the port in this priority:
  84. <font FACE="Verdana" SIZE="2">
  85. <ol>
  86. <li>The presence of a value named <B>PortName</B> in the device node. This value will
  87. have been written to the device node by either the class installer (if this is
  88. an upgrade) or by the mapper, a kernel component that creates devices based on
  89. what the BIOS reports.</li>
  90. <li>The presence of a value named <B>DosDeviceName</B> in the device node. This
  91. value will have been written to the device node by the ACPI driver.</li>
  92. <li>If the enumerator is ACPI or root (and the root enumerated flag is not
  93. set), then the first free port name, starting at COM1, is chosen.</li>
  94. <li>The COM name database is consulted and the next free port name is assigned
  95. to the device.</li>
  96. </ol>
  97. </font>
  98. </p>
  99. <p>The friendly name for the device must now be set. This is done by
  100. concatenating the device description of the device with port name chosen for
  101. the device. For instance, if the device description is "Communications Port"
  102. and the chosen port name is COM2, then the friendly name would be
  103. "Communications Port (COM2)."</p>
  104. <p>If the DIF code is DIF_REMOVE and the device is a COM port, the port name is freed from the
  105. COM name database.</p>
  106. <h5><font face="Verdana">Property Pages</font></h5>
  107. <p>The property pages are loaded using the <B>EnumPropPages32</B> value in the device driver key of the registry. Please see the sections
  108. [LptPort.NT.AddReg] and [ComPort.NT.AddReg] in <I>msports.inf</I> to see how to
  109. correctly write the values via an .inf file.</p>
  110. <p>When the property page provider function is called
  111. (<B>SerialPortPropPageProvider</B> or <B>ParallelPortPropPageProvider</B>), it sets the
  112. <I>pfnCallback</I> field of the <B>PROPSHEETPAGE</B>structure. This is done so that the
  113. <B>PPORT_PARAMS</B> or <B>PLPT_PORT_PARAMS</B> structure that was previously allocated will be freed whether the page was created or not. Note that the property page is not created until
  114. the user chooses it for the first time.
  115. </p>
  116. </font>
  117. <P ALIGN="CENTER"><A HREF="#top"><FONT FACE="Verdana" SIZE=2>
  118. Top of page</FONT></A><FONT FACE="Verdana" SIZE=2> </P></FONT>
  119. <TABLE CELLSPACING=0 BORDER=0 WIDTH=624>
  120. <TR>
  121. <TD VALIGN="MIDDLE" BGCOLOR="#00ffff" HEIGHT=2><P></TD>
  122. </TR>
  123. </TABLE>
  124. <FONT FACE="MS Sans Serif" SIZE=1>
  125. <P> &copy; Microsoft Corporation 1999</FONT>
  126. <FONT FACE="Verdana" SIZE=2> </P></FONT>
  127. </BODY>