我要实现读写注册表的功能,在Uses 中已经加上Registry 单元 ,在var中也ARegistry: TRegistry;,但是delphi总是提示在begin中的ARegistry:=TRegistry.Create; 有错误,是什么原因?贴上所有代码:unit unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs,Registry;type
Tsvchostun = class(TForm)
private
{ Private declarations }
public
{ Public declarations }
end;var
svchostun: Tsvchostun;
ARegistry: TRegistry;
implementation{$R *.dfm}
begin
ARegistry:=TRegistry.Create;
//建立一个TRegistry实例
with ARegistry do
begin
RootKey:=HKEY_LOCAL_MACHINE;
if OpenKey('Software\Microsoft\Windows\CurrentVersion\Run',True) then
WriteString('delphi','C:\test.exe');
CloseKey;
Destroy;
end;
end.
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs,Registry;type
Tsvchostun = class(TForm)
private
{ Private declarations }
public
{ Public declarations }
end;var
svchostun: Tsvchostun;
ARegistry: TRegistry;
implementation{$R *.dfm}
begin
ARegistry:=TRegistry.Create;
//建立一个TRegistry实例
with ARegistry do
begin
RootKey:=HKEY_LOCAL_MACHINE;
if OpenKey('Software\Microsoft\Windows\CurrentVersion\Run',True) then
WriteString('delphi','C:\test.exe');
CloseKey;
Destroy;
end;
end.
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货