Add control panel program on Windows mobile

Source: Internet
Author: User

In Windows mobile, users can access control panel applications through settings. Software developers can also access control panel information through the API functions provided by Windows mobile, for example, you can add a control panel application to it. The control panel application is implemented as a Dll, but must be suffixed with cpl. It exports a callback function: LONG CPlApplet (HWND hwndCPl, UINT msg, LPARAM lParam1, when a user clicks the settings, the ctlpnl.exe process will send messages by calling the CPlApplet. A cpl can support applets: hwndCPl: Control Panel window handle, it is the parent window of the applet. Msg: controls the messages sent by the panel program (ctlpnl.exe) to our application. These messages determine the application initialization, startup, stop, and exit. They mainly include: CPL_INIT, CPL_GETCOUNT, CPL_NEWINQUIRE, CPL_IDNAME, CPL_DBLCLK, CPL_STOP, and CPL_EXIT. CPL_INIT: The ctlpnl.exe notifies the control panel application to perform global initialization, such as memory allocation. CPL_GETCOUNT: obtains the number of small programs supported by Control Panel applications. CPL_NEWINQUIRE: Query Information about the applet of the Control Panel application. The information is contained in the NEWCPLINFO structure. CPL_IDNAME: Obtain the name of the Control Panel application. By setting the following registry key value, you can change the location of the application on the control panel property page. [HKEY_LOCAL_MACHINE/ControlPanel/<ID name>]. "Group" = dword: 1 Group value Settings tab where CPL exists 0 Personal 1 (default value) System 2 Connections CPL_DBLCLK: This message indicates that the user clicked the control panel application, you can start a process here to complete the corresponding work. CPL_STOP and CPL_EXIT: Stop messages and exit messages respectively. The following is a simple example: first create a Win32 Smart Device Project DLL Project of Smart Device, and add the following code: // TestCPL. cpp: Defines the entry point for the DLL application. # include "stdafx. h "# include <cpl. h> # define NUM_APPLETS 1 HINSTANCE g_hInstance = NULL; typedef struct tagApplets {int icon; // icon resource identifier int namestring; // name-string resource identifier int descstring; // description-string resource identifier} APPLETS; const APPLETS SystemApplets [] = {APPLET_ICON, APPLET_NAME, APPLET_DESC // add more struct members here if supporting more than on applet}; bool apientry DllMain (HANDLE hModule, DWORD program, LPVOID lpReserved) {if (DLL_PROCESS_ATTACH = Response) g_hInstance = (HINSTANCE) hModule; return TRUE;} BOOL InitApplet (HWND hwndParent) {return TRUE;} void TermApplet () {ret Urn ;} //////////////////////////////////////// ///// // This is the entry point called by ctlpnl.exe ////////////// //////////////////////////////////////// // long callback CPlApplet (HWND hwndCPL, UINT uMsg, LONG lParam1, LONG lParam2) {int iApplet; LPNEWCPLINFO lpNewCPlInfo; static int iInitCount = 0; switch (uMsg) {// First message sent. it is sent only once to // allow the dll to initi Alize 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 dll case CPL_GETCOUNT: return (LONG) NUM_APPLETS; // 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 NEWC PLINFO that shoshould be filled with information about // this applet before returning case failed: 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 (Syst EmApplets [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; case CPL_IDNAME: _ tcscpy (LPWSTR) lParam2, _ T ("Device Information"); break; // This is sent whenever the user clicks an icon in Settings for one of // the applets s Upported by this dll. lParam1 contains the number indicating // which applet. return 0 if applet successfully launched, non-zero otherwise case CPL_DBLCLK: iApplet = (UINT) lParam1; // LoadDialog (g_hInstance, hwndCPL); CreateProcess (_ T ("DeviceInfo.exe "), NULL, NULL); break; // Sent once per applet, before CPL_EXIT case CPL_STOP: break; // Sent once before the dll is u Nloaded case CPL_EXIT: iInitCount --; if (! IInitCount) TermApplet (); break; default: break;} return 0;} // TestCPL. def LIBRARY "TestCPL" EXPORTS DllMain CPlApplet. In addition, add the registry key value as follows: [HKEY_LOCAL_MACHINE/ControlPanel/Device Information]. "Group" = dword: 1

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.