How to invoke the device Properties dialog box from the application or from a command prompt (815320)
The information in this article applies to:
- Microsoft Windows 2000 Professional
- Microsoft Windows XP Professional
- Microsoft Windows Server 2003, Standard Edition
- Microsoft Windows Server 2003, Enterprise Edition
- Microsoft Windows Server 2003, Datacenter Edition
- Microsoft Windows Small Business Server 2003, Premium Edition
- Microsoft Windows Small Business Server 2003, Standard Edition
SUMMARYThis 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 INFORMATIONUsing 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 <options>
Arguments:
hwndStub - Windows handle to receive any message boxes that might appear.
hAppInstance - HINSTANCE.
lpCmdLine - Command line options passed in (for example, /DeviceID <device instance Id>).
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 <device instance Id>
This option specifies the device that the properties will be displayed for.
The caller must specify the DeviceId. It can be retrieved from the registry or from Device Manager. For more information about how to configure the Device Manager to display the DeviceId information, see the "References" section. - /MachineName <machine name>
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 programmaticallyTo 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 "DeviceProperties_RunDLLW"
typedef void (_stdcall *PDEVICEPROPERTIES)(
HWND hwndStub,
HINSTANCE hAppInstance,
LPWSTR lpCmdLine,
int nCmdShow
);
#else
#define DeviceProperties_RunDLL "DeviceProperties_RunDLLA"
typedef void (_stdcall *PDEVICEPROPERTIES)(
HWND hwndStub,
HHINSTANCE hAppInstance,
LPSTR lpCmdLine,
int nCmdShow
);
#endif
PDEVICEPROPERTIES pDeviceProperties;
HINSTANCE hDevMgr = LoadLibrary(_TEXT("devmgr.dll"));
if (hDevMgr) {
pDeviceProperties = (PDEVICEPROPERTIES)GetProcAddress((HMODULE)hDevMgr,
DeviceProperties_RunDLL);
}
if (pDeviceProperties){
pDeviceProperties(m_hWnd, hInst, _TEXT("/MachineName \"\" /DeviceID PCI\\VEN_8086\&DEV_2445\&SUBSYS_010E1028
\&REV_12\\3\&172E68DD\&0\&FD"), SW_SHOW);
}
Invoke from a command promptTo 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 "" /DeviceID root\system\0000
- rundll32.exe devmgr.dll,DeviceProperties_RunDLL
/DeviceID "PCI\VEN_8086&DEV_2445 &SUBSYS_010E1028&REV_12\3&172E68DD&0&FD"
Note If there is an ampersand symbol (&) in the device instance
ID, you must type double quotation marks around the ID. REFERENCES
For more information, click the following article numbers to view the articles in the Microsoft Knowledge Base:
304514
How to configure Device Manager to display detailed information
164787 Windows Rundll and Rundll32 interfaces
Modification Type: | Major | Last Reviewed: | 9/8/2005 |
---|
Keywords: | kbDDK kbhowto kbmgmtservices KB815320 kbAudDeveloper |
---|
|