控制面板Win7小程序 [英] Control panel Win7 applets

查看:445
本文介绍了控制面板Win7小程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在DelphiXe中,我通过项目主管创建了控制面板的新小程序,我更改了一个图标,名称等。
激活反应我写了Showmessage('Test');编译,接收dll,重命名为* .cpl。在此文件开头的win.explorer中显示该消息。
在WinXp中,我将这个文件插入到c:\windows\system32中,打开控制面板Windows,看到该applet,起初测试消息脱颖而出。
我在Win7x64(或2008r2)上做的最多,但是在小程序的控制面板中我没有观察到,重新启动问题并不能解决。
试图在c:\windows\syswow64中复制一个文件,也没有结果。
如何强制小程序会出现在Win7下的面板中?



代码:

 库Project1; 

使用
CtlPanel,
AppletModule1在AppletModule1.pas{AppletModule1AppletModule:TAppletModule}中;

导出CPlApplet;

{$ R * .RES}

{$ E cpl}

begin
Application.Initialize;
Application.CreateForm(TAppletModule1AppletModule,AppletModule1AppletModule);
Application.Run;
结束。

//////////////单元模块

单元AppletModule1;

接口

使用
Windows,消息,SysUtils,Classes,CtlPanel,Dialogs;

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

var
AppletModule1AppletModule:TAppletModule1AppletModule;

实现

{$ R * .DFM}

程序TAppletModule1AppletModule.AppletModuleActivate(发件人:TObject;
数据:整数);
begin
Showmessage('Test');
结束

结束。


解决方案

在XP上,您可以删除 .cpl 文件到系统文件夹,并完成:



如何注册DLL控制面板项目


从Windows XP起,新的控制面板项目DLL应安装在程序文件文件夹下相关应用程序的文件夹中。 存储在具有.cpl扩展名的System32目录中的项目不需要注册;它们将自动显示在控制面板中。使用CPlApplet的所有其他控制面板项必须以两种方式之一注册:




  • 如果所有用户都可以使用控制面板项目,请通过将REG_EXPAND_SZ值添加到HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Control来注册每台计算机上的路径Panel\Cpls子项,设置为DLL路径。


  • 如果控制面板项目在每个用户的基础上可用,请使用HKEY_CURRENT_USER作为根密钥而不是HKEY_LOCAL_MACHINE。



然而,在Vista和更高版本上,您的 .cpl applet需要在注册表中注册。在系统文件夹中删除它可能还不够。



开发控制面板


控制面板小程序的类型

控制面板小程序有三种类型:




  • 命令对象 - 运行指定的命令的applet注册表


  • Shell文件夹 - 小程序在控制面板中打开。 shell文件夹小程序的示例是字体文件夹,管理工具,个性化,系统,用户帐户和程序


  • 实现<$ c $的CPLs-applet c> CplApplet 函数




命令对象是最容易实现的。



添加和注册您自己的Applet和任务

在Windows Vista中将自己的小程序添加到控制面板更容易。软件开发人员现在可以轻松地将自己的小程序和任务添加到控制面板。



在以前的Windows版本中,您可以使用Windows注册表和CplApplet函数将applet添加到控制面板。操作系统使用注册表枚举包含小程序的模块。调用每个模块的CplApplet函数来显示小程序,其图标和描述,然后调用小程序。这个过程比使用命令对象更复杂,因为applet必须实现CplApplet接口。虽然在Windows Vista中仍然支持此过程,但由于使用命令对象更容易实现,所以使用命令对象。



现在,在Windows Vista中,您可以只写一个可执行文件(.exe),将其注册为一个命令对象,该小程序将显示在控制面板中。例如,您可以为您的小程序编写一个可执行文件MySystemApplet.exe,并将其添加到控制面板中将MySystemApplet.exe注册为shell命令对象,而不是用CplApplet接口的实现来繁琐地修改二进制文件。



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.

解决方案

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.

这篇关于控制面板Win7小程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆