让自己做的程序在开机后自动启动

方法一:将自己的程序添加到下面的键值中
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run
方法二:将自己的程序或快捷方式添加到开始-〉程序-〉启动 中
其他。。。
举例:
procedure TForm1.FormCreate(Sender: TObject);
var
myname:string;
const K = '\Software\Microsoft\Windows\CurrentVersion\Run';
begin
   myname := ExtractFilename(Application.Exename); 
  if application.Exename <> GetWindir + myname then
    begin
    //Copy self to system dir.
    copyfile(pchar(application.Exename), pchar(GetWindir + myname), False);
    application.Terminate;
    end;
    with TRegistry.Create do
        try
         RootKey := HKEY_LOCAL_MACHINE;
         OpenKey( K, TRUE );
         WriteString( 'system32',pchar(GetWindir + myname));
        finally
          free;
    end;
end;
 
[url]http://www.delphibbs.com/delphibbs/dispq.asp?lid=1395196[/url]

你可能感兴趣的:(职场,Delphi,休闲)