delphi怎样让程序开机自动运行

比如,我就一个空form1窗体,当我开机后,自动运行?
代码怎么写?
你可以在程悔枝序运行时自动写入注册表
uses中包含 Registry
var
MyFilePath:String;

begin
MyFilePath:=Application.ExeName ;
MyReg:=TRegistry.Create ;
MyReg.RootKey:= HKEY_CURRENT_USER;
MyReg.OpenKey('SoftWare\Microsoft\碧耐敏Windows\CurrentVersion\Run',True);
MyReg.WriteString ('myfile',MyFilePath );
MyReg.Free ;
这样做,一般会有杀毒软件进行拦截,需要同意才亩扰行。

你还可以直接把程序放到开始菜单中的启动下。
开机自启动是系统做的事情,者镇可以通过注册表配置或添加到开始菜单伏嫌枝的启缺敏动文件夹中;
当然这两个办法可以手动完成,也可以编程完成,编程代码我看有人贴了我就不贴了
unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, registry, StdCtrls;

type
TForm1 = class(TForm)
Button1: TButton; //用于控制程序的运行
Edit1: TEdit; //用于记录用户要添加的数值名称
Edit2: TEdit; /芹罩瞎/用于记录数值数据(即自启动程序的路径)
StaticText1: TStaticText;
procedure Button1Click(Sender: TObject);

private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;
implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
var
Reg:TRegistry; //首先定义一个闷亮TRegistry类型的变量Reg
begin

Reg:=TRegistry.Create; //创建一个新键
Reg.RootKey:=HKEY_LOCAL_MACHINE; //将根键设置为HKEY_LOCAL_MACHINE
Reg.OpenKey('SOFTWAREMicrosoftwindowsCurrentVersionRun',true);//打开一个键
Reg.WriteString(Edit1.Text,Edit2.Text); //在Reg这个键中写入数据名称和嫌空数据数值
Reg.CloseKey; //关闭键

end;

end.
Private Sub Form_Load()
Set w = CreateObject("wscript.shell"缺贺)
w.regwrite "HKLM\SOFTWARE\伏哗派Microsoft\Windows\CurrentVersion\Run\" & App.EXEName, App.Path & "芦银\" & App.EXEName & ".exe"
End Sub