Download the source code

Control Panel application is normal DLL that exports one function CPlApplet. The system will load all control panel application that are in the Windows folder. The application should have the extension .CPL. The control panel application can be accessed from the Settings.

The syntax for the function CPlApplet is :

LONG APIENTRY CPlApplet(HWND hwndCPl,UINT uMessage,LPARAM lParam1,LPARAM lParam2);

This function will be called by the Settings application. The hwndCPL member will be main window of the controlling application. This can be used as a parent window. The uMessage parameter is the message that is passed to the application. The parameters lParam1 and lParam2 depends on the message parameter.

Below are the possible messages and their descriptions:

CPL_INIT This message is the first message that will be send to the application. The application can initialize any resource for future use. The application should return TRUE if the initialization is successful otherwise FALSE.
CPL_GETCOUNT This is the second message passed to the application. Application should return the number if control panel application supported. A control panel DLL can support more that one application.
CPL_NEWINQUIRE This will be the third message passed to the application. The lParam1 will be the application number and the lParam2 will be a pointer to NEWCPLINFO structure. The application should fill the NEWCPLINFO structure with the information about the application such as name, description, icon, etc… The application should return 0 if successful otherwise a nonzero value.
CPL_STOP This message is passed to the application whenever the system is about the close the application. The application can perform any cleanup operation. A value of zero indicates success and nonzero value indicates failure.
CPL_EXIT This message is passed to the application when the system is about to free the control panel DLL. A value of zero indicates success and nonzero value indicates failure.

The sample provided here is a simple control panel application that will just display the memory usage of the system using a message box. A real control panel application may create a dialog and allow the user to set/change some of the system properties.