Re: open a .cpl file with Delphi

Posted by webmaster Guido on August 21, 2001

In Reply to: open a .cpl file posted by Delphilover on August 20, 2001

: is it possible to display control panel modules (*.cpl) files ? i have a little idea here i want to add a TMenuItem when the user chooses it i want to display the internet options dialogbox

Not so long ago, I have answered to the same question in DelphiLand's "Q&A Forum" -- just look a few messages before your question ;-) But since this seems to be quite a popular topic, let's talk about some more CPL stuff.

The "Control Panel" window contains icons that represent various utilities to set up, personalize and "tune" your system. These utilities are officially called the "Control Panel Extensions", but are also referred to as the "control panel applets". Most of these "applets" ("small applications") were added by Windows' installation program, others are added when you install additional Microsoft software, and even non-MicroSoft software can add their own.

While varying in number and type for different computers, a lot of the well-known "Control Panel Extensions" are common to all Windows 32-bit systems, such as: "Add/Remove Programs", "Display" (also called by right-clicking the desktop and selecting "Properties"), "Date/Time" (also available through the system-tray popup menu as "Adjust Date/Time"), and so on.

When you click an icon in Control Panel, Windows launches the program CONTROL.EXE (sits in the Windows directory) with the name of a CPL-file as a parameter. The CPL-files are located in Windows' System-directory. On the PC that I'm writing this text on, Windows' "Find Files or Folders" utility found 20 of them. Note that you also might find CPL-files in other folders, but these do not correspond with "Control Panel Extensions", they just happen to have the same file extension (example: some CorelDraw files such as pantone.cpl and trumatch.cpl).

But what is each CPL-file used for? Easy to find out: launch 'em through the Start-menu's "Run..." option, for example like this:
CONTROL C:\WINDOWS\SYSTEM\MAIN.CPL and discover that this is the one for "Mouse Properties".
And CONTROL C:\WINDOWS\SYSTEM\INTL.CPL calls the "Regional Settings Properties". Well, the filenames are not very informative :) and more over, some *.CPL files are *not* calling Control Panel utilities... Here are a few others that reside in the Windows\System directory, together with the title of the corresponding window that they opened on my test-PC:

desk.cpl : Display Properties
inetcpl.cpl : Internet Properties
mlcfg32.cpl : Microsoft Outlook Properties
mmsys.cpl : Multimedia Properties
modem.cpl : Modems Properties
netcpl.cpl : Network
sysdm.cpl : System Properties
timedate.cpl : Date/Time Properties

Of course, whatever can be launched with "Run...", can also be launched by any serious ;-) programming language. In Delphi, you accomplish this by calling the appropriate routine: please look at my previous answer to the question "open a .cpl" (July 24/27 2001). In addition, a click on the navigation button "Code Snips" at the left, opens a DelphiLand mini-tutorial called "Running an external application (and waiting)" plus the downloadable sources for a demo project.

[ DelphiLand Forum ] [ Delphi Tutorials ]