uses
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, Buttons,
ComCtrls, ActnList, StdCtrls, ExtCtrls,
Menus, RTTICtrls, crt ,
Windows,
ShlObj, ActiveX, ComObj,
ExtDlgs,win32proc;
//some uses are not necessary
var run:integer;
//run decides the autorunning on or off
procedure TForm1.Button7Click(Sender: TObject);
Var
IObject : IUnknown;
ISLink : IShellLink;
IPFile : IPersistFile;
TargetName : String;
LinkName : WideString;
Begin
if run=1 then
begin
TargetName :=application.ExeName;
IObject := CreateComObject(CLSID_ShellLink) ;
ISLink := IObject as IShellLink;
IPFile := IObject as IPersistFile;
with ISLink do
begin
SetPath(pChar(TargetName)) ;
SetWorkingDirectory(pChar(ExtractFilePath(TargetName))) ;
end;
if (windowsversion=wv7) or (windowsversion=wvlater) then
LinkName:='C:\ProgramData\Microsoft\Windows\Start Menu\Programs\StartUp\Menkal.lnk';
if windowsversion=wvxp then
LinkName:='C:\Documents and Settings\All Users\Start Menu\Program\Startup\Menkal.lnk';
IPFile.Save(PWChar(LinkName), false) ;
end
else
begin
if (windowsversion=wv7) or (windowsversion=wvlater) then
deletefile('C:\ProgramData\Microsoft\Windows\Start Menu\Programs\StartUp\Menkal.lnk');
if windowsversion=wvxp then
deletefile('C:\Documents and Settings\All Users\Start Menu\Program\Startup\Menkal.lnk');
end;
end; procedure TForm1.FormCreate(Sender: TObject);
begin
button7.Click;
end;procedure TForm1.FormClose(Sender: TObject; var CloseAction: TCloseAction);
begin
button7.Click;
end;this is the code i use, it can autorun program even change location of program, thanks taazz, maybe helpful for someone
And, i found that if i make a shortcut of a program to startup folder, then i move the program to another location, and double click the shortcut again, the program still open, so i check back the shortcut, program's location of it auto changed.

. i work on win 7, i don't know what happen in xp
regard

)