Click here to Skip to main content
13,251,605 members (73,853 online)
Click here to Skip to main content
Add your own
alternative version


32 bookmarked
Posted 30 Jul 2004

Device Property Sheet Dialog

, 12 Aug 2004
Rate this:
Please Sign up or sign in to vote.
Showing property sheet dialog of a specific device.

Sample Image - DevicePropertySheet.jpg


In my last article (Enumerate Properties of an Installed Device), I used Setup APIs to enumerate all of the properties of an installed device. But these properties are common for all devices and there were no specific properties that differ with other devices' properties. For example, a sound card has some properties that are different with properties of a network adapter.

Also, during these months, several developers asked me for device specific properties and how can one change them programmatically. I searched over the net but I could not find any related article. Now, this article is my effort to solving the problem.

Reverse Engineering The Device Manager

The first step is searching the MSDN. I searched the MSDN to find any API related to Device Manager; for example, an API that gets some information about a device (e.g., DevNode, Device GUID or etc.) and shows a dialog (may be Device Property Sheet) of properties. But there is no such API. At least, I can't find any, if anyone knows such an API, I would be glad to be informed.

The second step is to study more about the Device Manager. The Device Manager is a DLL (DevMgr.dll) that is used in MMC as a snap-in. Figure 2 shows it:

Device Manager

I used PE File Explorer (a free utility with source code) for exploring PE (Portable Executable) files like *.exe, *.dll, *.ocx, and etc.

With this utility, I found exported functions. That made an idea for me. How can other programs call these exported (and also undocumented) functions to show device property sheets?

Figure 3 shows PEFileExplorer that opens DevMgr.dll.

Sample screenshot

A big step was done with PEFileExplorer. Now I know which functions are exported by the DLL, and this makes me to search about exported functions.

From MSDN, I found that Rundll.exe and Rundll32.exe allow to invoke a function exported from a DLL. However, Rundll and Rundll32 programs do not allow you to call any exported function from any DLL. For example, you can not use these utility programs to call the Win32 API (Application Programming Interface) calls exported from the system DLLs. The programs only allow you to call functions from a DLL that are explicitly written to be called by them.

The command line for Rundll32.exe is as follows:

Rundll32.exe <name of dll> 
       <entry point function> <arguments>

With a deep look on the list of exported functions, everyone can understand that the entry point of DevMgr.dll is DeviceProperties_RunDLLA (ANSI version) and DeviceProperties_RunDLLW (UNICODE version). As Microsoft Knowledge Base Article - 164787 suggests, Rundll32.exe can handle the entry point function without using A or W. In other words, we are required to call the entry point as follows:

Rundll32.exe devmgr.dll DeviceProperties_RunDLL /DeviceID 

The above syntax means Rundll32.exe should call DeviceProperties_RunDll (as an entry point of DevMgr.dll) and pass /DeviceID root\system\0000 as argument of the function.


In the previous article, I showed you how we can obtain DeviceID of an installed device. Then by calling Rundll32.exe with proper arguments, the property sheet of an installed device will appear.

The following code shows an example:

void CDevicePropertySheetDialogDlg::OnDeviceProperty() 
    DEVNODE dn;
    for (int i=0; i<m_Devices.GetItemCount(); i++)
        if (m_Devices.GetItemState(i, LVIS_SELECTED)) //item was selected
            dn=(DEVNODE) m_Devices.GetItemData(i);
    CString CommandLine;

    //Enumerate properties
    for (int j=0; j<DeviceProperty.size(); j++)
        if (DeviceProperty[j].dn==dn)
                  DeviceProperties_RunDLL /DeviceID \"%s\""),
    ShellExecute(m_hWnd, _T("open"), _T("Rundll32.exe"), 
                                CommandLine, NULL, SW_SHOW);

I assume that all of the devices listed in a list view control (m_Devices) and properties of the device (including DeviceID) are saved in DevicePropert vector.

Alternative Way

An alternative way is to load DevMgr.dll dynamically with LoadLibrary API. Here is the changed code to load the device property sheet with LoadLibrary API:

void CDevicePropertySheetDialogDlg::OnDeviceProperty() 
    DEVNODE dn;

    for (int i=0; i<m_Devices.GetItemCount(); i++)
        if (m_Devices.GetItemState(i, LVIS_SELECTED)) //item was selected
            //AfxMessageBox(m_Devices.GetItemText(i, 0));
            dn=(DEVNODE) m_Devices.GetItemData(i);

    CString CommandLine;

    //Enumerate properties
    for (int j=0; j<DeviceProperty.size(); j++)
        if (DeviceProperty[j].dn==dn)
            CommandLine.Format(_T("/MachineName \"\" /DeviceID %s"),


    PDEVICEPROPERTIES pDeviceProperties;
    HINSTANCE hInst=AfxGetInstanceHandle();
    HINSTANCE  hDevMgr = LoadLibrary(_TEXT("devmgr.dll"));
    if (hDevMgr) 
        pDeviceProperties = (PDEVICEPROPERTIES) GetProcAddress((HMODULE) hDevMgr, 

    if (pDeviceProperties)
        pDeviceProperties(m_hWnd, hInst, CommandLine.GetBuffer(0), SW_SHOW);


It should be noticed that DeviceProperties_RunDLL is defined as below:

#ifdef _UNICODE 
#define DeviceProperties_RunDLL  "DeviceProperties_RunDLLW"
typedef void (_stdcall *PDEVICEPROPERTIES)(
                   HWND hwndStub,
                   HINSTANCE hAppInstance,
                   LPWSTR lpCmdLine,
                   int    nCmdShow

#define DeviceProperties_RunDLL  "DeviceProperties_RunDLLA"
typedef void (_stdcall *PDEVICEPROPERTIES)(
                   HWND hwndStub,
                   HINSTANCE hAppInstance,
                   LPSTR lpCmdLine,
                   int    nCmdShow

Thanks to Martin Rubas for his comment.



This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

A. Riazi
CEO Misbah3Com
Iran (Islamic Republic of) Iran (Islamic Republic of)
I was born in Shiraz, a very beautiful famous city in Iran. I started programming when I was 12 years old with GWBASIC. Since now, I worked with various programming languages from Basic, Foxpro, C/C++, Visual Basic, Pascal to MATLAB and now Visual C++.
I graduated from Iran University of Science & Technology in Communication Eng., and now work as a system programmer for a telecommunication industry.
I wrote several programs and drivers for Synthesizers, Power Amplifiers, GPIB, GPS devices, Radio cards, Data Acqusition cards and so many related devices.
I'm author of several books like Learning C (primary and advanced), Learning Visual Basic, API application for VB, Teach Yourself Object Oriented Programming (OOP) and etc.
I'm winner of January, May, August 2003 and April 2005 best article of month competetion, my articles are:

You can see list of my articles, by clicking here

You may also be interested in...


Comments and Discussions

GeneralMy vote of 5 Pin
Amir Mohammad Nasrollahi9-Aug-13 21:32
professionalAmir Mohammad Nasrollahi9-Aug-13 21:32 
GeneralMy vote of 5 Pin
manoj kumar choubey26-Feb-12 20:56
membermanoj kumar choubey26-Feb-12 20:56 
GeneralAdd an extra device property tab into device Properties Pin
charle_hsin8-Jul-09 11:57
membercharle_hsin8-Jul-09 11:57 
Hi Riazi, did you ever try to add an extra device property tab into device Properties window? I am trying to do this, but haven't be able to do it yet in Windows 7.
GeneralMoshkel dar tashkhiseh Cart Seda (Sound Cards) Pin
koorosh4-Jan-07 8:27
memberkoorosh4-Jan-07 8:27 
QuestionUninstall device from the Device Manager Pin
araravikar27-Apr-06 10:32
memberararavikar27-Apr-06 10:32 
AnswerRe: Uninstall device from the Device Manager Pin
A. Riazi28-Apr-06 1:59
memberA. Riazi28-Apr-06 1:59 
GeneralRe: Uninstall device from the Device Manager Pin
araravikar28-Apr-06 12:46
memberararavikar28-Apr-06 12:46 
AnswerRe: Uninstall device from the Device Manager Pin
A. Riazi28-Apr-06 15:48
memberA. Riazi28-Apr-06 15:48 
QuestionHow to open COM Port Advanced Settings Pin
quantum197615-Feb-06 20:32
memberquantum197615-Feb-06 20:32 
GeneralRetrieve USB Info Pin
LiYS28-Oct-05 7:18
memberLiYS28-Oct-05 7:18 
GeneralRe: Retrieve USB Info Pin
A. Riazi28-Oct-05 22:23
memberA. Riazi28-Oct-05 22:23 
GeneralRe: Retrieve USB Info Pin
LiYS29-Oct-05 6:10
memberLiYS29-Oct-05 6:10 
GeneralRe: Retrieve USB Info Pin
A. Riazi30-Oct-05 3:18
memberA. Riazi30-Oct-05 3:18 
GeneralRe: Retrieve USB Info Pin
LiYS30-Oct-05 15:48
memberLiYS30-Oct-05 15:48 
GeneralCapture device signal detection Pin
tony070731-Aug-05 11:48
membertony070731-Aug-05 11:48 
GeneralEnable / Disable network card device Pin
ARTsoft31-May-05 6:20
sussARTsoft31-May-05 6:20 
GeneralExported Functions... Pin
daDude26-Oct-04 23:28
memberdaDude26-Oct-04 23:28 
GeneralRe: Exported Functions... Pin
A. Riazi27-Oct-04 1:11
memberA. Riazi27-Oct-04 1:11 
GeneralNice work, but look at MS KB 815320 Pin
Merlin99cz8-Aug-04 23:40
memberMerlin99cz8-Aug-04 23:40 
GeneralDLL Application Pin
Ernest Laurentin2-Aug-04 6:45
memberErnest Laurentin2-Aug-04 6:45 
GeneralRe: DLL Application Pin
A. Riazi2-Aug-04 8:17
memberA. Riazi2-Aug-04 8:17 
GeneralRe: DLL Application Pin
Ernest Laurentin2-Aug-04 14:46
memberErnest Laurentin2-Aug-04 14:46 
GeneralGood Pin
norm.net1-Aug-04 22:17
membernorm.net1-Aug-04 22:17 
GeneralRe: Good Pin
A. Riazi1-Aug-04 22:57
memberA. Riazi1-Aug-04 22:57 
GeneralWon't compile...fixed Pin
doctrane1-Aug-04 17:04
memberdoctrane1-Aug-04 17:04 
GeneralRe: Won't compile...fixed Pin
A. Riazi1-Aug-04 22:54
memberA. Riazi1-Aug-04 22:54 
GeneralRe: Won't compile...fixed Pin
eddie204619-Aug-04 14:48
membereddie204619-Aug-04 14:48 
GeneralRe: Won't compile...fixed Pin
A. Riazi19-Aug-04 20:19
memberA. Riazi19-Aug-04 20:19 
QuestionRe: Won't compile...fixed Pin
GreatestMaverick27-Mar-06 20:26
memberGreatestMaverick27-Mar-06 20:26 
AnswerRe: Won't compile...fixed Pin
A. Riazi27-Mar-06 20:29
memberA. Riazi27-Mar-06 20:29 
GeneralGood work! Pin
Ryan Binns31-Jul-04 20:33
memberRyan Binns31-Jul-04 20:33 
GeneralRe: Good work! Pin
A. Riazi31-Jul-04 20:46
memberA. Riazi31-Jul-04 20:46 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web03 | 2.8.171114.1 | Last Updated 13 Aug 2004
Article Copyright 2004 by A. Riazi
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid