Executing Code as a Control Panel Item through an Exported Cplapplet Function
This is a quick note that shows how to execute code in a .cpl file, which is a regular DLL file representing a Control Panel item.
The .cpl file needs to export a function
CplAppletin order to be recognized by Windows as a Control Panel item.
Once the DLL is compiled and renamed to .CPL, it can simply be double clicked and executed like a regular Windows .exe file.
// dllmain.cpp : Defines the entry point for the DLL application.
extern "C" __declspec(dllexport) LONG Cplapplet(
MessageBoxA(NULL, "Hey there, I am now your control panel item you know.", "Control Panel", 0);
BOOL APIENTRY DllMain( HMODULE hModule,
Cplapplet(NULL, NULL, NULL, NULL);
Once the DLL is compiled, we can see our exported function
Below shows that double-clicking the .cpl item is enough to launch it:
CPL file can also be launched with
control.exe <pathtothe.cpl>like so:
or with rundll32:
rundll32 shell32, Control_RunDLL \\VBOXSVR\Experiments\cpldoubleclick