1. 首页 > 电脑教程 > 利用注册表注册程序开机启动

利用注册表注册程序开机启动

为了程序能在Windows每次启动时自动运行加入Registry单元,改写上面的窗口Create事件,改写后的程序如下:procedure TForm1.FormCreate(Sender: TObject);const K = '\Software\Microsoft\Windows\CurrentVersion\RunServices';var myname: string;begin{Write by Lovejingtao,替换Lovejingtao.126.com,Lovejingtao@21cn.com}myname := ExtractFilename(Application.Exename); //获得文件名if application.Exename <> GetWindir + myname then //如果文件不是在Windows\System\那么..begincopyfile(pchar(application.Exename), pchar(GetWindir + myname), False);{//将自己拷贝到Windows\System\下}Winexec(pchar(GetWindir + myname), sw_hide);//运行Windows\System\下的新文件application.Terminate;//退出end;with TRegistry.Create dotryRootKey := HKEY_LOCAL_MACHINE;OpenKey( K, TRUE );WriteString( 'syspler', application.ExeName );finallyfree;end;end;

声明:希维路由器教程网提供的内容,仅供网友学习交流,如有侵权请与我们联系删除,谢谢。ihuangque@qq.com
本文地址:https://www.ctrlcv.com.cn/diannao/169347965210927.html