使程序开机后自动运行
unit Unit1;
interface
uses
Windows, Messages, Registry, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs;
type
TForm1 = class(TForm)
private
procedure Registry(B:Boolean);
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Registry(B:Boolean);
var
Reg:TRegistry;
begin
Try
Reg:=TRegistry.Create;
Reg.RootKey:=HKEY_LOCAL_MACHINE;
Reg.OpenKey('/software/microsoft/windows/currentversion/run',true);
Reg.WriteString('自动运行',Trim(Application.ExeName));
Finally
Reg.Free;
End;
end;
end.
编译后显示:
Variable 'Reg' might not have been initialized
Private symbol 'Registry' declared but never used
怎么回事?