| RTL reference|Glossary|Tips/Tricks|FREE App/VCL|Essentials|Books|Link Back |
| Locate, Display and Execute Control Panel Applets | |||||||||||||||||||||||
| Page 2: Inside Control Panel Applets: Extracting a Name, Description and the Icon | |||||||||||||||||||||||
Interested in Delphi code to mimic the Windows Control Panel folder behavior? In this article you can learn how to find CPL files, how to extract description, name and even the applet icon. Even more, learn how to execute applets from your applications.
Once we have found all Control Panel applications inside the Windows System folder, we can "look" inside, and extract any information we need.
But, first some info on how CPL files are "structured".
Every Control Panel application exports the standard entry-point function, named CPlApplet. This function receives requests, in the form of messages (like "CPL_SOMETHING"), and carries out the requested work, such as initializing the application, returning a number of dialog boxes it supports, providing information about a specified dialog box, and closing the application.
Therefore, after we have dynamically loaded the CPL, in order to look inside the CPL application we need to "find" the CPlApplet function. This is done by calling the GetProcAddress API call.
Once we lay our hands on the CPlApplet function, we use it to grab the information about the Contol Panel Application we want. First, we send it the CPL_GetCount message to get the number of dialog boxes (Applets) it carries. Remember that each .CPL file is an application that can hold more than one Applet. Second, for each Applet, we send the CPL_INQUIRE message that fills the CPLInfo structure. This structure contains resource information (such as the name of the applet, description and icon) and an application-defined value for a dialog box supported by a Control Panel application. Finally, we use LoadIcon and LoadString API calls to get the information we are interested in.
When we have finished with the Control Panel application (the CPL file), we unload it using the FreeLibrary function.
Uh, the "story" above looks quite messy ;) Don't runaway, Delphi code looks much more friendly.
![]() The ProcessCPLApplet function
Note: the TCPLApplet and the TCPLInfo types are defined in the Delphi CPL.pas unit, which you will have to include in the uses clause. The LoadStringFromModule is a function defined in the project used to extract the string value (stored as a resource) inside the CPLInfo structure. All set, we have a Delphi clone of the Windows Control Panel folder, now we proceed to executing a particular applet! Next page > Executing Control Panel Applets from Delphi > Page 1, 2, 3, 4 |
|||||||||||||||||||||||
All graphics (if any) in this feature created by Zarko Gajic.
| More Delphi |
|
· Learn another routine every day - RTL Quick Reference. · Download free source code applications and components. · Talk about Delphi Programming, real time. · Link to the Delphi Programming site from your Web pages. · Tutorials, articles, tech. tips by date: 2003|2002|2001|2000|1999|1998 or by TOPIC. |
| Stay informed with all new and interesting things about Delphi (for free). |
|
|
| Got some code to share? Got a question? Need some help? |


