?? devcon.htm
字號:
<h4><span style='font-family:Verdana'>Reboot<o:p></o:p></span></h4>
<p><span style='font-size:10.0pt;font-family:Verdana'>This function shows how
to correctly reboot the machine from a hardware install program. In particular
it passes flags to <span class=SpellE>ExitWindowsEx</span> that cause the
reboot to be associated with hardware installation. You should never reboot the
machine unnecessarily.<o:p></o:p></span></p>
<h4><span class=SpellE><span style='font-family:Verdana'>EnumerateDevices</span></span><span
style='font-family:Verdana'><o:p></o:p></span></h4>
<p><span style='font-size:10.0pt;font-family:Verdana'>Demonstrates the use of <span
class=SpellE>SetupDiGetClassDevsEx</span> to enumerate all devices or all
present devices, either globally or limited to a specific setup class.
Demonstrates the use of <span class=SpellE>SetupDiCreateDeviceInfoListEx</span>
to create a blank list associated with a class or not (for most cases, a blank
list need not be associated with a class). Demonstrates the use of <span
class=SpellE>SetupDiOpenDeviceInfo</span> to add a device instance into a
device info list. These last two API's are ideal to obtain a <span
class=SpellE>DeviceInfoData</span> structure from a device instance and machine
name when mixing CFGMGR32 API's with SETUPAPI API's. <span class=SpellE>SetupDiGetDeviceInfoListDetail</span>
is called to obtain a remote machine handle that may be passed into CFGMGR32
API's. <span class=SpellE>SetupDiEnumDeviceInfo</span> is called to enumerate
each and every device that is in the device info list (either explicitly added,
or determined by the call to <span class=SpellE>SetupDiGetClassDevsEx</span>).
The instance ID is obtained by calling <span class=SpellE>CM_Get_Device_ID_Ex</span>,
using information in <span class=SpellE>devInfo</span> (obtained from <span
class=SpellE>SetupDiEnumerateDeviceInfo</span>) and <span class=SpellE>devInfoListDetail</span>
(obtained from <span class=SpellE>SetupDiGetDeviceInfoListDetail</span>). <span
class=SpellE>GetHwIds</span> is called to obtain a list of hardware and
compatible ID's (explained below). Once an interesting device has been
determined (typically by checking hardware ID's) then the callback is called to
operate on that individual device.<o:p></o:p></span></p>
<h4><span class=SpellE><span style='font-family:Verdana'>GetHwIds</span></span><span
style='font-family:Verdana'><o:p></o:p></span></h4>
<p><span style='font-size:10.0pt;font-family:Verdana'>Shows how to get the
complete list of hardware ID's or compatible ID's for a device using <span
class=SpellE>SetupDiGetDeviceRegistryProperty</span>.<o:p></o:p></span></p>
<h4><span class=SpellE><span style='font-family:Verdana'>GetDeviceDescription</span></span><span
style='font-family:Verdana'><o:p></o:p></span></h4>
<p><span style='font-size:10.0pt;font-family:Verdana'>Shows how to obtain
descriptive information about a device. The friendly name is used if it exists,
otherwise the device description is used.<o:p></o:p></span></p>
<h4><span class=SpellE><span style='font-family:Verdana'>DumpDeviceWithInfo</span></span><span
style='font-family:Verdana'><o:p></o:p></span></h4>
<p><span style='font-size:10.0pt;font-family:Verdana'>Shows how to obtain an
instance ID (or use any CFGMGR32 API) given HDEVINFO (device info list) and
PSP_DEVINFO_DATA (device info data).<o:p></o:p></span></p>
<h4><span class=SpellE><span style='font-family:Verdana'>DumpDeviceStatus</span></span><span
style='font-family:Verdana'><o:p></o:p></span></h4>
<p><span style='font-size:10.0pt;font-family:Verdana'>Shows how to interpret
the information returned by <span class=SpellE>CM_Get_DevNode_Status_Ex</span>.
Refer to <span class=SpellE>cfg.h</span> for information returned by this API. <o:p></o:p></span></p>
<h4><span class=SpellE><span style='font-family:Verdana'>DumpDeviceResources</span></span><span
style='font-family:Verdana'><o:p></o:p></span></h4>
<p><span style='font-size:10.0pt;font-family:Verdana'>Shows how to obtain
information about resources used by a device.<o:p></o:p></span></p>
<h4><span class=SpellE><span style='font-family:Verdana'>DumpDeviceDriverFiles</span></span><span
style='font-family:Verdana'><o:p></o:p></span></h4>
<p><span style='font-size:10.0pt;font-family:Verdana'>Provided as a debugging
aid, obtains information about the files apparently being used for a device. It
uses <span class=SpellE>SetupDiBuildDriverInfoList</span> to obtain information
about the driver being used for the specified device. The driver list associated
with a device may be enumerated by calling <span class=SpellE>SetupDiEnumDriverInfo</span>.
In this case, there will be no more than one driver listed. This function
proceeds to obtain a list of files that would normally be copied for this
driver using DIF_INSTALLDEVICEFILES. <span class=SpellE>SetupScanFileQueue</span>
is used to enumerate the file queue to display the list of files that are
associated with the driver.<o:p></o:p></span></p>
<h4><span class=SpellE><span style='font-family:Verdana'>DumpDeviceDriverNodes</span></span><span
style='font-family:Verdana'><o:p></o:p></span></h4>
<p><span style='font-size:10.0pt;font-family:Verdana'>Provided as a debugging
aid, this function determines the list of compatible drivers for a device. It
uses <span class=SpellE>SetupDiBuildDriverInfoList</span> to obtain the list of
compatible drivers. In this case, all drivers are enumerated, however typically
DIF_SELECTBESTCOMPATDRV and <span class=SpellE>SetupDiGetSelectedDriver</span>
would be used together to find which driver the OS would consider to be the
best. <o:p></o:p></span></p>
<h4><span class=SpellE><span style='font-family:Verdana'>DumpDeviceStack</span></span><span
style='font-family:Verdana'><o:p></o:p></span></h4>
<p><span style='font-size:10.0pt;font-family:Verdana'>This function determines
class and device upper and lower filters. <o:p></o:p></span></p>
<h3><span style='font-family:Verdana'>BUILDING THE DEVCON SAMPLE<o:p></o:p></span></h3>
<h5><span style='font-family:Verdana'>To build the <span class=SpellE>devcon</span>
sample:<o:p></o:p></span></h5>
<p class=MsoListNumber style='margin-left:.5in;text-indent:-.25in;mso-list:
l1 level1 lfo3;tab-stops:list .5in'><![if !supportLists]><span
style='font-size:10.0pt;font-family:Verdana;mso-fareast-font-family:Verdana;
mso-bidi-font-family:Verdana'><span style='mso-list:Ignore'>1.<span
style='font:7.0pt "Times New Roman"'> </span></span></span><![endif]><span
style='font-size:10.0pt;font-family:Verdana'>Click the Build Environment icon of
choice in the Development Kits Build Environments sub-menu. This will set up
the correct build environment to build this sample. Note that this sample will
build in the 64-bit environments as well as the 32-bit environments. <o:p></o:p></span></p>
<p class=MsoListNumber style='margin-left:.5in;text-indent:-.25in;mso-list:
l1 level1 lfo3;tab-stops:list .5in'><![if !supportLists]><span
style='font-size:10.0pt;font-family:Verdana;mso-fareast-font-family:Verdana;
mso-bidi-font-family:Verdana'><span style='mso-list:Ignore'>2.<span
style='font:7.0pt "Times New Roman"'> </span></span></span><![endif]><span
style='font-size:10.0pt;font-family:Verdana'>In a command window, change to the
directory containing the <span class=SpellE>DevCon</span> source code. For
example:<o:p></o:p></span></p>
<blockquote style='margin-top:5.0pt;margin-bottom:5.0pt'>
<p style='margin-left:.5in'><span class=SpellE><b><span style='font-size:10.0pt;
font-family:Verdana'>cd</span></b></span><b><span style='font-size:10.0pt;
font-family:Verdana'> <span class=SpellE>src\setup\devcon</span></span></b><span
style='font-size:10.0pt;font-family:Verdana'> <o:p></o:p></span></p>
</blockquote>
<p class=MsoListNumber style='margin-left:.5in;text-indent:-.25in;mso-list:
l1 level1 lfo3;tab-stops:list .5in'><![if !supportLists]><span
style='font-size:10.0pt;font-family:Verdana;mso-fareast-font-family:Verdana;
mso-bidi-font-family:Verdana'><span style='mso-list:Ignore'>3.<span
style='font:7.0pt "Times New Roman"'> </span></span></span><![endif]><span
style='font-size:10.0pt;font-family:Verdana'>Use the macro BLD or run the
following from the command prompt: <o:p></o:p></span></p>
<blockquote style='margin-top:5.0pt;margin-bottom:5.0pt'>
<p><b><span style='font-size:10.0pt;font-family:Verdana'>build 朿</span></b><span
style='font-size:10.0pt;font-family:Verdana'> <o:p></o:p></span></p>
<p><span style='font-size:10.0pt;font-family:Verdana'>This invokes the
Microsoft make routines that produce the <span class=SpellE>Build.log</span>, <span
class=SpellE>Build.wrn</span>, and <span class=SpellE>Build.err</span> log
files. <o:p></o:p></span></p>
<p><span style='font-size:10.0pt;font-family:Verdana'>When the build completes,
the executable will be placed in the ObjXXX\I386 subdirectory of the
<TARGETPATH> directory specified in the Sources file (depending on build
environment chosen). <o:p></o:p></span></p>
<p><span style='font-size:10.0pt;font-family:Verdana'>If the build does not
succeed, check for these errors: 1) the build environment is not set up
properly, or 2) modifications made to the sample source code introduced errors.
<o:p></o:p></span></p>
</blockquote>
<h3><span style='font-family:Verdana'>USING DEVCON<o:p></o:p></span></h3>
<p><span class=SpellE><span style='font-size:10.0pt;font-family:Verdana'>DevCon</span></span><span
style='font-size:10.0pt;font-family:Verdana'> is provided in ready-to-run form
in tools\<span class=SpellE>devcon</span>. For usage, refer to the document
provided with devcon.exe. <span class=SpellE>DevCon</span> is a command line
utility with built-in documentation available by typing "<span
class=SpellE>devcon</span> help". <o:p></o:p></span></p>
<h3><span style='font-family:Verdana'>TESTING<o:p></o:p></span></h3>
<p><span style='font-size:10.0pt;font-family:Verdana'>Type "<span
class=SpellE>devcon</span> find *" to list device instances of all present
devices on the local machine.<o:p></o:p></span></p>
<p><span style='font-size:10.0pt;font-family:Verdana'>Type "<span
class=SpellE>devcon</span> status @root\rdp_mou\0000" to list status of
the terminal server mouse driver.<o:p></o:p></span></p>
<p><span style='font-size:10.0pt;font-family:Verdana'>Type "<span
class=SpellE>devcon</span> status *PNP05*" to list status of all COM
ports.<o:p></o:p></span></p>
<h3><span style='font-family:Verdana'>CODE TOUR<o:p></o:p></span></h3>
<h4><span style='font-family:Verdana'>File Manifest<o:p></o:p></span></h4>
<table class=MsoNormalTable border=0 cellspacing=1 cellpadding=0 width=916
style='width:687.0pt;mso-cellspacing:.7pt;mso-padding-alt:0in 0in 0in 0in'>
<tr style='mso-yfti-irow:0;mso-yfti-firstrow:yes'>
<td width=151 valign=top style='width:113.25pt;padding:0in 0in 0in 0in'>
<p class=MsoNormal><u>File</u></p>
</td>
<td width=755 style='width:566.25pt;padding:0in 0in 0in 0in'>
<p class=MsoNormal><u>Description</u></p>
</td>
</tr>
<tr style='mso-yfti-irow:1'>
<td width=151 valign=top style='width:113.25pt;padding:0in 0in 0in 0in'>
<p class=MsoNormal><i>DevCon.htm</i></p>
</td>
<td width=755 style='width:566.25pt;padding:0in 0in 0in 0in'>
<p class=MsoNormal>Sample tour documentation for this binary (this file).</p>
</td>
</tr>
<tr style='mso-yfti-irow:2'>
<td width=151 valign=top style='width:113.25pt;padding:0in 0in 0in 0in'>
<p class=MsoNormal><span class=SpellE><i>DevCon.cpp</i></span></p>
</td>
<td width=755 style='width:566.25pt;padding:0in 0in 0in 0in'>
<p class=MsoNormal>Source file for <span class=SpellE>tmain</span> entry point
and utility functions.</p>
</td>
</tr>
<tr style='mso-yfti-irow:3'>
<td width=151 valign=top style='width:113.25pt;padding:0in 0in 0in 0in'>
<p class=MsoNormal><span class=SpellE><i>Cmds.cpp</i></span></p>
</td>
<td width=755 style='width:566.25pt;padding:0in 0in 0in 0in'>
<p class=MsoNormal>Source file for supported commands.</p>
</td>
</tr>
<tr style='mso-yfti-irow:4'>
<td width=151 valign=top style='width:113.25pt;padding:0in 0in 0in 0in'>
<p class=MsoNormal><span class=SpellE><i>Dump.cpp</i></span></p>
</td>
<td width=755 style='width:566.25pt;padding:0in 0in 0in 0in'>
<p class=MsoNormal>Source file for functions that output information about
devices.</p>
</td>
</tr>
<tr style='mso-yfti-irow:5'>
<td width=151 valign=top style='width:113.25pt;padding:0in 0in 0in 0in'>
<p class=MsoNormal><span class=SpellE><i>DevCon.h</i></span></p>
</td>
<td width=755 style='width:566.25pt;padding:0in 0in 0in 0in'>
<p class=MsoNormal>Header file for sample.</p>
</td>
</tr>
<tr style='mso-yfti-irow:6'>
<td width=151 valign=top style='width:113.25pt;padding:0in 0in 0in 0in'>
<p class=MsoNormal><span class=SpellE><i>DevCon.rc</i></span></p>
</td>
<td width=755 style='width:566.25pt;padding:0in 0in 0in 0in'>
<p class=MsoNormal>Resource file containing some strings and version
information.</p>
</td>
</tr>
<tr style='mso-yfti-irow:7'>
<td width=151 valign=top style='width:113.25pt;padding:0in 0in 0in 0in'>
<p class=MsoNormal><span class=SpellE><i>rc_ids.h</i></span></p>
</td>
<td width=755 style='width:566.25pt;padding:0in 0in 0in 0in'>
<p class=MsoNormal>Header file for resources.</p>
</td>
</tr>
<tr style='mso-yfti-irow:8'>
<td width=151 valign=top style='width:113.25pt;padding:0in 0in 0in 0in'>
<p class=MsoNormal><span class=SpellE><i>Msg.mc</i></span></p>
</td>
<td width=755 style='width:566.25pt;padding:0in 0in 0in 0in'>
<p class=MsoNormal>Message file that is used to build <span class=SpellE>msg.rc</span>
and <span class=SpellE>msg.h</span> used for help texts and other messages.</p>
</td>
</tr>
<tr style='mso-yfti-irow:9'>
<td width=151 valign=top style='width:113.25pt;padding:0in 0in 0in 0in'>
<p class=MsoNormal><i>Sources</i></p>
</td>
<td width=755 style='width:566.25pt;padding:0in 0in 0in 0in'>
<p class=MsoNormal>Generic file that lists source files and all the build
options.</p>
</td>
</tr>
<tr style='mso-yfti-irow:10;mso-yfti-lastrow:yes'>
<td width=151 valign=top style='width:113.25pt;padding:0in 0in 0in 0in'>
<p class=MsoNormal><span class=SpellE><i>Makefile</i></span></p>
</td>
<td width=755 style='width:566.25pt;padding:0in 0in 0in 0in'>
<p class=MsoNormal>File that redirects to the real make file that is shared
by all the driver components of the Windows DDK.</p>
</td>
</tr>
</table>
<h3><span style='font-family:Courier'>FEEDBACK<o:p></o:p></span></h3>
<p><span style='font-family:Courier'>We welcome your comments, problem reports and
wish-list requests. Please submit them by pointing your Internet browser to <a
href="http://www.microsoft.com/ddk">http://www.microsoft.com/ddk</a>. </span></p>
<p align=center style='text-align:center'><span style='font-size:10.0pt;
font-family:Verdana'><a href="#top">Top of page</a><o:p></o:p></span></p>
<table class=MsoNormalTable border=0 cellspacing=0 cellpadding=0 width=624
style='width:6.5in;mso-cellspacing:0in;mso-padding-alt:0in 5.4pt 0in 5.4pt'>
<tr style='mso-yfti-irow:0;mso-yfti-firstrow:yes;mso-yfti-lastrow:yes;
height:1.5pt'>
<td style='background:aqua;padding:.75pt .75pt .75pt .75pt;height:1.5pt'>
<p class=MsoNormal><span style='font-size:2.0pt;mso-bidi-font-size:12.0pt'><o:p> </o:p></span></p>
</td>
</tr>
</table>
<p><span style='font-size:7.5pt;font-family:"MS Sans Serif"'>
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -