This article explains how to extract a list of available Control Panel applications and how to execute them from the command line or from another program.
Back to the top
The Control.exe file is a utility included with Windows 95, Windows 98, Windows NT 4.0, Windows 2000, Windows XP, and Windows 2003 that launches control panel applications. Applications can use the following command line to start a Control Panel applet:
C:\>control.exe mycontrol.cpl
This starts the first Control Panel applet in Mycontrol.cpl. If you have multiple Control Panel applets in Mycontrol.cpl, you need to add the name of the Control Panel applet to the command line as demonstrated in the following:
Control.exe Mycontrol.cpl,My Control
To enumerate the list of available Control Panel applications in a *.cpl file, you can use the following program sample code:
// Control Panel Enumeration
#include <stdio.h>
#include <windows.h>
#include <cpl.h>
int main(int argc, char **argv, char **envp)
{
union {
NEWCPLINFOA NewCplInfoA;
NEWCPLINFOW NewCplInfoW;
} Newcpl;
HINSTANCE hLib; // Library Handle to *.cpl file
APPLET_PROC CplCall; // Pointer to CPlApplet() function
LONG i;
// -------------------
if (!(hLib = LoadLibrary(argv[1])))
return 1;
if (!(CplCall=(APPLET_PROC)GetProcAddress(hLib,"CPlApplet")))
{
FreeLibrary(hLib);
return 2;
}
// -------------------
CplCall(NULL, CPL_INIT,0,0); // Init the *.cpl file
for (i=0;i<CplCall(NULL,CPL_GETCOUNT,0,0);i++)
{
printf("Control %s",argv[1]);
Newcpl.NewCplInfoA.dwSize = 0;
Newcpl.NewCplInfoA.dwFlags = 0;
CplCall(NULL,CPL_NEWINQUIRE,i,(long)&Newcpl);
if (Newcpl.NewCplInfoA.dwSize == sizeof(NEWCPLINFOW))
{ // Case #1, CPL_NEWINQUIRE has returned an Unicode String
wprintf(L",%s\n", Newcpl.NewCplInfoW.szName);
}
else
{ // Case #2, CPL_NEWINQUIRE has returned an ANSI String
if (Newcpl.NewCplInfoA.dwSize != sizeof(NEWCPLINFOA))
{
// Case #3, CPL_NEWINQUIRE failed to return a string
// Get the string from the *.cpl Resource instead
CPLINFO CInfo;
CplCall(NULL,CPL_INQUIRE,i,(long)&CInfo);
LoadStringA(hLib,CInfo.idName,
Newcpl.NewCplInfoA.szName,32);
}
printf(",%s\n", Newcpl.NewCplInfoA.szName);
}
} // for
CplCall(NULL,CPL_EXIT,0,0);
// -------------------
FreeLibrary(hLib);
return 0;
}
This program (Enumcpl.exe) will take one *.cpl file as a parameter and print the available Control Panel applications in that file.
For example, to enumerate all installed *.cpl files on a system:
C:\>for %i in ( c:\winnt\system32\*.cpl ) do @enumcpl %i
Control c:\winnt\system32\ups.cpl,&UPS
Control c:\winnt\system32\telephon.cpl,Telephony
Control c:\winnt\system32\ups.cpl,&UPS
Control c:\winnt\system32\telephon.cpl,Telephony
Control c:\winnt\system32\srvmgr.cpl,Ser&ver
Control c:\winnt\system32\srvmgr.cpl,Servi&ces
Control c:\winnt\system32\srvmgr.cpl,&Devices
Control c:\winnt\system32\ncpa.cpl,Network
Control c:\winnt\system32\main.cpl,Mouse
Control c:\winnt\system32\main.cpl,Keyboard
Control c:\winnt\system32\main.cpl,Printers
Control c:\winnt\system32\main.cpl,Fonts
Control c:\winnt\system32\odbccp32.cpl,OD&BC
Control c:\winnt\system32\console.cpl,Console
Control c:\winnt\system32\appwiz.cpl,Add/Remove Programs
Control c:\winnt\system32\access.cpl,Accessibility Options
Control c:\winnt\system32\inetcpl.cpl,Internet
Control c:\winnt\system32\DESK.CPL,Display
Control c:\winnt\system32\DEVAPPS.CPL,PC Card (PCMCIA)
Control c:\winnt\system32\DEVAPPS.CPL,SCSI Adapters
Control c:\winnt\system32\DEVAPPS.CPL,Tape Devices
Control c:\winnt\system32\INTL.CPL,Regional Settings
Control c:\winnt\system32\MMSYS.CPL,Multimedia
Control c:\winnt\system32\MMSYS.CPL,Sounds
Control c:\winnt\system32\MODEM.CPL,Modems
Control c:\winnt\system32\PORTS.CPL,Ports
Control c:\winnt\system32\SYSDM.CPL,System
Control c:\winnt\system32\TIMEDATE.CPL,Date/Time
Any one of these lines can be executed to start the corresponding Control Panel application from the command line.
Using RunDLL32 can also be used to debug a Control Panel application, by using the RunDLL32.exe as the program and the string generated above as the arguments to RunDLL32.
Back to the top
For more information, click the following article numbers to view the articles in the Microsoft Knowledge Base:
135068 (http://support.microsoft.com/kb/135068/)
How to start a Control Panel applet in Windows 95, 98, WinNT, Windows 2000, XP, 2003
164787 (http://support.microsoft.com/kb/164787/) The Windows 95 Rundll and Rundll32 interface
166168 (http://support.microsoft.com/kb/166168/) How to use Rundll32 to debug Control Panel applets
183106 (http://support.microsoft.com/kb/183106/) How to debug Control Panel property sheet extensions
192806 (http://support.microsoft.com/kb/192806/) How to run Control Panel tools by typing a command
Back to the top