Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

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


View products that this article applies to.

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.

↑ Back to the top


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 <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 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 "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 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 "" /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.

↑ Back to the top


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

↑ Back to the top


Keywords: kbdswlhwrapup, kbdswlhapplies, kbdswddkwindows2003swept, kbmgmtservices, kbddk, kbhowto, kb

↑ Back to the top

Article Info
Article ID : 815320
Revision : 4
Created on : 8/1/2019
Published on : 8/1/2019
Exists online : False
Views : 371