What is a control panel program? You can see it at a glance. The control panel application is a file suffixed with CPL, which is actually a DLL file (change the suffix of the DLL file generated by the project to CPL, or modify the configuration from vs to directly produce the CPL file ). Deploying the control panel program is very simple. Copy the generated CPL file to the Windows directory of your mobile phone. The ctlpnl.exe process loads the corresponding CPL file in the Windows directory when you click the graphic icon of the panel program compiled by Alibaba.
In fact, some Control Panel programs provided by the system are integrated in cplmain. cpl (but like a wireless manager, it is not a CPL file, but an EXE program. This can be found in the registry, microsoft designed this because wireless manager is needed in many places .), So if you need to open these panels in your program, you will often see the following code:
Shellexecuteinfo Info; tchar szcontrolpanelpolicline [200]; swprintf (szcontrolpanelpolicline, l // windows // cplmain. CPL, 5); // parameter 5 indicates calling aboutinfo. cbsize = sizeof (Info); info. fmask = see_mask_nocloseprocess | see_mask_flag_no_ui; info. lpverb = NULL; info. lpfile = text ("ctlpnl.exe"); info. lpparameters = szcontrolpanelpolicline; info. lpdirectory = NULL; info. nshow = sw_show; info. hinstapp = NULL; shellexecuteex (& info );
Here are more mappings:
Ctlpnl.exe cplmain. CPL, 1-SET Password
Ctlpnl.exe cplmain. CPL, 2-set ownerinfo
Ctlpnl.exe cplmain. CPL, 3-Battery status
Ctlpnl.exe cplmain. CPL, 4-memory status
Ctlpnl.exe cplmain. CPL, 5-about
Ctlpnl.exe cplmain. CPL, 7-align
Ctlpnl.exe cplmain. CPL, 8-keyboard settings
Ctlpnl.exe cplmain. CPL, 9-sound
Ctlpnl.exe cplmain. CPL, 10-Remove Programs
Ctlpnl.exe cplmain. CPL, 11-Start Menu
Ctlpnl.exe cplmain. CPL, 12-button assignments
Ctlpnl.exe cplmain. CPL, 13-Today Screen
Ctlpnl.exe cplmain. CPL, 15-beam settings
Ctlpnl.exe cplmain. CPL, 16-clock
Ctlpnl.exe cplmain. CPL, 17-network adapters
Ctlpnl.exe cplmain. CPL, 18-regional settings
Ctlpnl.exe cplmain. CPL, 19-connections
Ctlpnl.exe cplmain. CPL, 20-phone settings
Ctlpnl.exe cplmain. CPL, 22-manage certificates
Ctlpnl.exe cplmain. CPL, 23-Bluetooth
Let's get started with writing CPL
In the cplfile, the callback cplappletis the ctlpnl.exe process that enters your CPl entry point (you need to export, whether you are in the def file or define the dllexport Attribute before the function). a cpl supports multiple applets, see the comments in the following code.
LONG CPlApplet( HWND hwndCPl, //Handle to the main window of the controlling application. UINT msg, //Message being sent to the Control Panel application. LPARAM lParam1, LPARAM lParam2);
MSG:
Cpl_init
Initialization: the control panel application performs global initialization, such as memory allocation.
Cpl_getcount
Obtain the number of dialog boxes supported by the Control Panel application.
Cpl_newinquire
Query the dialog boxes information of the Control Panel application. The information is contained inLparam2Parameter, use (lpnewcplinfo)Lparam2Obtain the pointer.
typedef struct tagNEWCPLINFO { DWORD dwSize; DWORD dwFlags; DWORD dwHelpContext; LONG lData; HICON hIcon; //Handle to the icon that represents the dialog box. TCHAR szName[32]; //The name is intended to be displayed below the icon. TCHAR szInfo[64]; //The description is intended to be displayed when the icon for the dialog
Box is selected. tcharSzhelpfile [128]; // Ignore. To use help, process the wm_notify message and obtain
Get"Lppsn= (Lppshnotify)Lparam; "To determine whether it is equal to psn_help. If yes, the help document can be called up .} Newcplinfo;
Cpl_idname
Obtain the name of the Control Panel application by setting the registry key value[HKEY_LOCAL_MACHINE/ControlPanel/<ID name>]
You can change the location of an application on the properties page of the control panel,The default primary key value "group" is DWORD type 1. That is to say, if you do not specify a position, it is placed in the system tab by default. You can also select the following values:
0
Personal
1 (default value)System
2Connections
Cpl_dblclk
When you double-click the icon on the control panel, the system will send this message to your control facial application. At this time, you can bring up a dialog box. After the message is processed, 0 indicates that you have successfully processed the message (the same is true for other messages), and 0 indicates other messages.
Cpl_stop
Send this message to your control panel application the moment before closing the facial control application.
Cpl_exit
Send this message to your control panel application at the moment before releasing the DLL file.
//////////////////////////////////////////////////////////This is the entry point called by ctlpnl.exe// ////////////////////////////////////////////////////////extern "C"__declspec(dllexport)LONG WINAPI CPlApplet(HWND hwndCPL, UINT uMsg, LONG lParam1, LONG lParam2){static intiInitCount = 0;intiApplet; switch (uMsg){// First message sent. It is sent only once to// allow the dll to initialize it's applet(s)case CPL_INIT:if (!iInitCount){if (!InitApplet(hwndCPL))return FALSE;}iInitCount++;return TRUE;// Second message sent. Return the count of applets supported// by this dllcase CPL_GETCOUNT:// Return the number of applets we supportreturn (LONG)((sizeof(SystemApplets))/(sizeof(SystemApplets[0])));// Third message sent. Sent once for each applet supported by this dll.// The lParam1 contains the number that indicates which applet this is// for, from 0 to 1 less than the count of applets.// lParam2 is a NEWCPLINFO that should be filled with information about// this applet before returningcase CPL_NEWINQUIRE:{LPNEWCPLINFOlpNewCPlInfo;lpNewCPlInfo = (LPNEWCPLINFO)lParam2;iApplet = (int)lParam1;lpNewCPlInfo->dwSize = (DWORD)sizeof(NEWCPLINFO);lpNewCPlInfo->dwFlags = 0;lpNewCPlInfo->dwHelpContext= 0;lpNewCPlInfo->lData = SystemApplets[iApplet].icon;lpNewCPlInfo->hIcon =
LoadIcon(g_hInstance,
(LPCTSTR)MAKEINTRESOURCE(SystemApplets[iApplet].icon));lpNewCPlInfo->szHelpFile[0]= '/0';LoadString(g_hInstance,SystemApplets[iApplet].namestring,
lpNewCPlInfo->szName,32);LoadString(g_hInstance,SystemApplets[iApplet].descstring,
lpNewCPlInfo->szInfo,64);}break;// This is sent whenever the user clicks an icon in Settings for one of// the applets supported by this dll. lParam1 contains the number indicating// which applet. Return 0 if applet successfully launched, non-zero otherwisecase CPL_DBLCLK:iApplet = (UINT)lParam1;if (!CreatePropertySheet(hwndCPL,iApplet))return 1;break;// Sent once per applet, before CPL_EXITcase CPL_STOP:break;// Sent once before the dll is unloadedcase CPL_EXIT:iInitCount--;if (!iInitCount)TermApplet();break;default:break; } return 0;}
For more detailed code, see examples/samples/pocketpc/CPP/Win32/mybacklight, or click here to download.
For any CPL code debugging, refer to the following article.
Author: Wang Kewei
Source: http://wangkewei.cnblogs.com/
Copyright: The copyright of this article is shared by the author and the blog. The detailed link of this article must be noted during reprinting; otherwise, the author will reserve the right to pursue its legal liability.