ZZ Windows Control Panel programming __ Programming

Source: Internet
Author: User

ZZ from:http://blog.csdn.net/tomcui/archive/2008/01/22/2058502.aspx


Windows Control Panel Programming

Note: This article for me in the project to check the relevant articles written, if there are improper, please point out.

Mail:tomcui60000520@163.com

Key words:

Control Panel, Control Panel application,

One, What is the control Panel

Open Windows Control Panel to see a similar image

Figure I

Double-click on one of the icons, will display a dialog box, so that users to complete the corresponding hardware and software settings work. This is what we see in the control Panel. So how to develop the Control Panel program. Search for the keyword "Control Panel" in MSDN and Google with questions, and you'll find relevant technical articles. This is the way I work: draw on the resources already available. But is that actually the case? We can follow the MSDN story step-by-step.

After digging, found not exe file (Windows Vista support EXE Control Panel application, and Microsoft proposed EXE file), but with a CPL suffix name files, in Windows->system32 can find such a file. If you use a tool, Dependency Walker for Win32 (x86) or DUMPBIN, you can see that the file has exported some functions.

Figure II

By looking at several of these files, you find that the exported functions are different, but there are cplapplet functions that are exported. These features coincide with the characteristics of the DLL. A description of the Cplapplet function on MSDN proves that our guesses are correct. It can be said that the control panel should be the program is a CPL suffix name and be sure to export the Cplapplet function DLL file.

For a specific description you can refer to:

http://msdn2.microsoft.com/en-us/library/bb776838 (vs.85). aspx

Second, define a few concepts

L Control Panel Management Program: The program used to manage the control Panel, in the desktop Windows version is CONTROL.EXE, in the Windows CE version is CTLPNL.EXE, they are responsible for managing control Panel entries in the dashboard. To put it simply, when we open the Control Panel, these management programs are running. But what we see is the appearance of the shell (note: This is my guess, I haven't found the basis yet).

Control Panel Entry: The Control Panel entry corresponds to each icon that is seen in the control Panel.

L Control Panel application (controllerapplication): The CPL file that is eventually seen, a control panel application can implement several control Panel entries.

Third, authoring of Control Panel applications

Writing a Control panel application is to write a DLL file that implements the functionality required for control in the file. This involves a function that has to be said, without which the implementation of the Control Panel program cannot be completed. The function is Cplapplet. The following is a description of the function's parameters.

Function: LONG cplapplet (HWND hwndcpl,uint msg, LPARAM lParam1, LPARAM lParam2)

The function Cplapplet is the entry point of the Control Panel application, Control Panel application, which is controlled by the console management program (control.exe or Ctlpnl.exe) is invoked automatically, it is a callback function (Callback), note: The CPL file must export the function Cplapplet so that the control Panel can find the entry point of the program.

When you start Control Panel, it searches for files in the directory of the corresponding entries in Windows or System32 or registry, and loads the file with the CPL as an extension, calling the exported function of the CPL file Cplapplet () to send the message to the function. Therefore, the Control Panel application handles the message that the control Panel sends over, which is handled in function Cplapplet, which has no default behavior. If multiple control Panel programs are implemented in a CPL file, there will be only one cplapplet function, which is responsible for all Control panel applications.

Parameter description:

HWNDCPL: The Control Panel Management program or the window handle called the control Panel, which is the window handle of the control.exe. You can use this parameter if the Control Panel application or other window needs to pass the parent window handle.

MSG: The message sent to the Control Panel application is sent by the Control Panel management program.

LPARAM1: Message Parameters

LPARAM2: Message Parameters

The return value of a function is different depending on the message.

The application needs to include a header file to use this function: cpl.h

Message name

Describe

Cpl_init

The first message received by the Control Panel application, which typically handles global initialization and memory allocation. A successful return of non-0, or 0, at which point the Control Panel management program terminates communication with the application and releases the corresponding CPL file.

Cpl_getcount

The message is sent immediately after the CPL_INIT message, which returns the number of Control Panel components that the CPL file can see in the control Panel, as seen by the Control Panel management program.

Cpl_inquire

is sent after the Cpl_getcount to provide information for the specified control Panel entry.

Cpl_newinquire

is sent after Cpl_getcount, similar to the functionality of the message Cpl_inquire completion, except that its implementation requires TNEWCPLINFO structure pointers and that the contained resources do not provide caching, so the control Panel starts slowly and generally does not recommend handling the message unless it is particularly necessary. If you want to change the Control Panel entry icon, string, etc. dynamically according to certain conditions.

Cpl_dblclk

Indicates that the user has selected a Control Panel entry, and the program should display the corresponding dialog box so that the user can complete the task. Returns 0 successfully, otherwise, returns a non-0.

Cpl_stop

The Control Panel manager is sent when the program is closed, and the Control Panel application handles the memory release action at this time. Successfully processed, returns 0.

Cpl_select

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.