有时需要让Windows在启动时自动运行你的程序,如何在程序中实现呢?
使用Regedit查找HKEY_LOCALMACHINE\Sodtware\Microsoft\Windows\CurrentVersion\Run,你会发现所有的Windows启动时调用的程序都在这里,于是你将你的程序增加在这里就可以了.名称为你的程序的标题,其值为你的程序的执行路径和文件名称. 在程序头部加入 Uses Registry,在程序中如下写(以开机运行金山词霸为例) var tempreg:TRegistry; begin tempreg:=TRegistry.Create; tempreg.RootKey:=HKEY_LOCAL_MACHINE; tempreg.OpenKey('SOFTWARE\Microsoft\Windows\CurrentVersion\Run',True); tempreg.WriteString('金山词霸','"C:\Program Files\jscb3\xdict.exe"'); tempreg.Closekey; tempreg.Free; end;
二 有时需要让Windows在启动时自动运行你的程序,如何在程序中实现呢?
使用Regedit查找HKEY_LOCALMACHINE\Sodtware\Microsoft\Windows\CurrentVersion\Run,你会发现所有的Windows启动时调用的程序都在这里,于是你将你的程序增加在这里就可以了.名称为你的程序的标题,其值为你的程序的执行路径和文件名称. 如Interbase: Interbase Server"D:\Program Files\Borland\IntrBase\BIN\ibserver.exe"
在程序中实现可以使用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('Interbase Server', '"D:\Program Files\Borland\IntrBase\BIN\ibserver.exe"'); except ... End; RegF.Close; RegF.Free; end;
|