Launch control panel apps programmatically.

2 04 2008

Icon Description
Normally for launching control panel application you have to go to control panel and double click the icons. Its useful if we can launch it programmatically. For instance, if the program wants the user to check the computer name, the system properties can be launched. If the program wants to uninstall some software, for easiness – the add/remove programs dialog can be launched and so and so…

Icon How Can I Do It?
There is an undocumented api – “Control_RunDLL” in the Shell32.dll which can be used to launch control panel applications. You’ve to pass the filename of control Panel application and it will be launched. See the following code block.

// Load the Shell32 dll.
HINSTANCE hShell32 = LoadLibrary(_T("Shell32.dll"));

// Typedef for function pointer for Control_RunDLL.
                                                 HINSTANCE hinst,
                                                 LPSTR lpszCmdLine,
                                                 int nCmdShow );

// Get the function pointer of - Control_RunDLL.
  (CONTROL_RUNDLL_FN_PTR)GetProcAddress( hShell32,

// Now call the function and launch the ControlPanel App.
(*pControl_RunDLL)( 0, // hwnd
                    0, // Hinstance
                    _T("sysdm.cpl"), // ControlPanelApp filename.
                    SW_NORMAL );     // Show Normal

Icon - Where is it?
The control panel applications are located inside your windows directory. If you search the windows directory for “*.cpl” you can find a number of files. Each file is a control panel application. Even though the file extension is “.cpl“, its a dll. From the name itself you can interpret which control panel application it refers to. Go on, have a try. 😉

Icon Note
For launching some control panel apps, you’ve to provide valid hwnd and hinstance. Then only it will be shown. For instance – timedate.cpl.

Targeted Audience – Intermediate.