可以在注册表里的
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run
下面建立一个键值,代码如下:uses registry;
...
var
    temp:string;
    reg: tregistry;
begin
    reg := tregistry.Create;
    reg.RootKey := HKEY_LOCAL_MACHINE;
    reg.OpenKey('SOFTWARE\Microsoft\Windows\CurrentVersion\Run', false);
    if not reg.ValueExists('MyApp') then
    begin
      temp := application.ExeName;
      reg.WriteString('MyApp', temp);
    end;
    reg.Free;
end;

解决方案 »

  1.   

    我写的一个通用的函数
    FUNCTION WriteStartRun: Boolean;
    VAR
      reg               : tregistry;
    BEGIN
      result := true;
      reg := tregistry.Create;
      TRY    Reg.RootKey := HKEY_LOCAL_MACHINE
        reg.OpenKey('\SOFTWARE\Microsoft\Windows\CurrentVersion\Run', true);
        reg.WriteString(application.Title , application.ExeName);
      FINALLY
        Reg.CloseKey;
        Reg.Free;
      END;END;
      

  2.   

    你也可以这样做,将如下的文字保存为".Reg"文件然后双击该文件图表即可。
    注:pserver为一个任意的名字
       "C:\\windows\\system\\pserver.exe  /autorun"为路径,目录间以\\分开REGEDIT4[HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run]
    "PServer"="C:\\windows\\system\\pserver.exe  /autorun"
      

  3.   

    三种方法:
    1、在注册表的RUN键下加值;
    2、在“程序”-“启动”菜单中加入一个快捷方式;
    3、在AutoExec.bat中写运行程序的语句。
      

  4.   

    有时需要让Windows在启动时自动运行你的程序,如何在程序中实现呢?
    使用Regedit查找HKEY_LOCALMACHINE\Sodtware\
    Microsoft\Windows\CurrentVersion\Run,你会发现所有的Windows启动时调用的程序都在这里,于是你将你的程序增加在这里就可以了。名称为你的程序的标题,其值为你的程序的执行路径和文件名称。
    在程序中实现可以使用TRegIniFile或者使用TRegistry都可以。
        User Registry;
        Var RegF:TRegistry;
        begin
         RegF:=TRegistry.Create;
         RegF.RootKey:=HKEY_LOCAL_MACHINE;
        try
         RegF.OpenKey('SOFTWARE\Microsoft\Windows\CurrentVersion\Run',True);
         RegF.WriteString('MyProg', "Mypr-og.exe"');
        except
         ...
         End; {try}
        RegF.Close;
       RegF.Free;
        end;