Control panel Win7 applets

試著忘記壹切 提交于 2019-12-31 05:29:11

问题


In DelphiXe I create through the master of projects the new applet of the Control panel, I change an icon, the name, etc. To activation reactions I write Showmessage (' Test '); Compile, receive dll, rename in *.cpl. In a win.explorer at start of this file the message appears. In WinXp I insert this file in c:\windows\system32, open Control panel Windows, I see the applet and at its start the test message stands out. I make too most on Win7x64 (or on 2008r2), but in the control panel of the applet I do not observe, reboot of a problem does not solve. Tried to duplicate a file in c:\windows\syswow64, too there is no result. How to force the applet will appear in the panel under Win7?

Code:

library Project1;

uses
 CtlPanel,
 AppletModule1 in 'AppletModule1.pas' {AppletModule1AppletModule: TAppletModule};

exports CPlApplet;

{$R *.RES}

{$E cpl}

begin
 Application.Initialize;
 Application.CreateForm(TAppletModule1AppletModule, AppletModule1AppletModule);
 Application.Run;
end.

////////////// and Unit module

unit AppletModule1;

interface

uses
 Windows, Messages, SysUtils, Classes, CtlPanel, Dialogs;

type
 TAppletModule1AppletModule = class(TAppletModule)
   procedure AppletModuleActivate(Sender: TObject; Data: Integer);
 private
 { private declarations }
 protected
 { protected declarations }
 public
 { public declarations }
 end;

var
 AppletModule1AppletModule: TAppletModule1AppletModule;

implementation

{$R *.DFM}

procedure TAppletModule1AppletModule.AppletModuleActivate(Sender: TObject;
 Data: Integer);
begin
Showmessage('Test');
end;

end.

回答1:


On XP, you can drop the .cpl file into the system folder and be done with it:

How to Register DLL Control Panel Items

As of Windows XP, new Control Panel item DLLs should be installed in the associated application's folder under the Program Files folder. Items that are stored in the System32 directory with a .cpl extension do not need to be registered; they are automatically shown in the Control Panel. All other Control Panel items that use CPlApplet must be registered in one of two ways:

  • If the Control Panel item is to be available to all users, register the path on a per-computer basis by adding a REG_EXPAND_SZ value to the HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Control Panel\Cpls subkey, set to the DLL path.

  • If the Control Panel item is to be available on a per-user basis, use HKEY_CURRENT_USER as the root key instead of HKEY_LOCAL_MACHINE.

However, on Vista and later, your .cpl applet needs to be registered in the Registry. Dropping it in the system folder may not be enough.

Developing for the Control Panel

Types of Control Panel Applets
There are three types of Control Panel applets:

  • Command objects—applets that run commands specified in the registry

  • Shell folders—applets open up in the Control Panel. Examples of shell folder applets are the Fonts Folder, Administrative Tools, Personalization, System, User Accounts, and Programs

  • CPLs—applets that implement the CplApplet function

Command objects are the easiest to implement.

Adding and Registering Your Own Applets and Tasks
Adding your own applet to Control Panel is easier in Windows Vista. Software developers can now easily add their own applets and tasks to Control Panel.

In previous versions of Windows, you add applets to the Control Panel by using the Windows Registry and the CplApplet function. The operating system uses the Registry to enumerate the modules containing the applets. Each module's CplApplet function is called to display the applet, its icon and description, and then invoke the applet. This process is more complicated than using command objects because the applet must implement the CplApplet Interface. Although this process is still supported in Windows Vista, using command objects is encouraged since it is easier to implement.

Now, in Windows Vista, you can just write an executable (.exe), register it as a command object and the applet appears in Control Panel. For example, you can write an executable, MySystemApplet.exe, for your applet and add the applet to Control Panel by simply registering MySystemApplet.exe as a shell command object instead of tediously modifying the binary with an implementation of the CplApplet interface.



来源:https://stackoverflow.com/questions/5951440/control-panel-win7-applets

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!