Microsoft KB Archive/815320

= How to invoke the device Properties dialog box from the application or from a command prompt =

Article ID: 815320

Article Last Modified on 12/3/2007

-

APPLIES TO


 * Microsoft Windows 2000 Professional Edition
 * Microsoft Windows XP Professional
 * Microsoft Windows Server 2003, Standard Edition (32-bit x86)
 * Microsoft Windows Server 2003, Enterprise Edition (32-bit x86)
 * Microsoft Windows Server 2003, Datacenter Edition (32-bit x86)
 * Microsoft Windows Small Business Server 2003 Premium Edition
 * Microsoft Windows Small Business Server 2003 Standard Edition

-



SUMMARY
This article describes how to invoke the device Properties dialog box in the application or from a command prompt by using the DeviceProperties_RunDLL function.



MORE INFORMATION
Using Device Manager, you can start the device Properties dialog box for a specific device. By using the DeviceProperties_RunDLL function from the Devmgr.dll file, users can run the device Properties dialog box either programmatically or from a command prompt.

Function prototype
void DeviceProperties_RunDLL(   HWND hwndStub,    HINSTANCE hAppInstance,    LPCTSTR lpCmdLine,    int    nCmdShow    ) /*++   Routine Description: This API opens the property pages for the specified device.

This function can be executed by means of a rundll command line and will have the following form: rundll32.exe devmgr.dll, DeviceProperties_RunDLL

Arguments:

hwndStub - Windows handle to receive any message boxes that might appear. hAppInstance - HINSTANCE. lpCmdLine - Command line options passed in (for example, /DeviceID ).

nCmdShow - Flag that specifies how device manager should be shown when it is opened. It can be one of the SW_ values (for example, SW_SHOW).

Return Value:

none --*/

Command line options
The following command line options are accepted by the DeviceProperties_RunDLL function:

Note The option names, /DeviceId and /MachineName, are not case-sensitive.
 * /DeviceId 

This option specifies the device that the properties will be displayed for. The caller must specify the. It can be retrieved from the registry or from Device Manager. For more information about how to configure the Device Manager to display the  information, see the &quot;References&quot; section.
 * /MachineName

This option specifies the machine name where the device belongs to. This option is required if the function is used in an application in Windows 2000 operating system, that is, you must specify this option even the machine name is empty in the case of a local machine.

Invoke programmatically
To invoke the device Properties dialog box programmatically, you have to load Devmgr.dll and then obtain the address of the function. You also have to define a macro to make it map to an appropriate prototype (Unicode or Non-Unicode). Following is the sample code: #ifdef _UNICODE #define DeviceProperties_RunDLL &quot;DeviceProperties_RunDLLW&quot; typedef void (_stdcall *PDEVICEPROPERTIES)(      HWND hwndStub,       HINSTANCE hAppInstance,       LPWSTR lpCmdLine,       int    nCmdShow       );

#else #define DeviceProperties_RunDLL &quot;DeviceProperties_RunDLLA&quot; typedef void (_stdcall *PDEVICEPROPERTIES)(      HWND hwndStub,       HHINSTANCE hAppInstance,       LPSTR lpCmdLine,       int    nCmdShow       ); #endif

PDEVICEPROPERTIES pDeviceProperties; HINSTANCE hDevMgr = LoadLibrary(_TEXT(&quot;devmgr.dll&quot;)); if (hDevMgr) { pDeviceProperties = (PDEVICEPROPERTIES)GetProcAddress((HMODULE)hDevMgr,                               DeviceProperties_RunDLL); }

if (pDeviceProperties){ pDeviceProperties(m_hWnd, hInst, _TEXT(&quot;/MachineName \&quot;\&quot; /DeviceID PCI\\VEN_8086\&DEV_2445\&SUBSYS_010E1028 \&REV_12\\3\&172E68DD\&0\&FD&quot;), SW_SHOW); }

Invoke from a command prompt
To invoke the device Properties dialog box from a command prompt, run commands like the following commands:
 * rundll32.exe devmgr.dll,DeviceProperties_RunDLL /DeviceID root\system\0000
 * rundll32.exe devmgr.dll,DeviceProperties_RunDLL /MachineName &quot;&quot; /DeviceID root\system\0000
 * rundll32.exe devmgr.dll,DeviceProperties_RunDLL /DeviceID &quot;PCI\VEN_8086&DEV_2445 &SUBSYS_010E1028&REV_12\3&172E68DD&0&FD&quot;

Note If there is an ampersand symbol (&) in the device instance ID, you must type double quotation marks around the ID.

