导航:
论坛 -> DELPHI技术
斑竹:liumazi,sephil
作者:
2004/7/5 14:01:49
标题:
如何将程序加入启动中,在开机后自动运行?
浏览:1415
加入我的收藏
楼主:
如题:
----------------------------------------------
-
作者:
sephil (NAILY Soft)
★☆☆☆☆
-
盒子中级会员
2004/7/5 14:05:03
1楼:
这是偶的VirtualDrive里的一段 const H_RootKey = HKEY_CURRENT_USER; S_KeyName = 'NS VirtualDrive'; S_RunKey = 'Software\Microsoft\Windows\CurrentVersion\Run'; S_AutorunParam = '/Autorun'; procedure TConfigForm.DeleteAutorun; begin with TRegistry.Create do try RootKey := H_RootKey; if OpenKey(S_RunKey, False) then DeleteValue(S_KeyName); finally Free; end; end; procedure TConfigForm.WriteAutorun; begin with TRegistry.Create do try RootKey := H_RootKey; if OpenKey(S_RunKey, True) then WriteString(S_KeyName, ParamStr(0) + ' ' + S_AutorunParam); finally Free; end; end;
----------------------------------------------
Copyright 2008 ? NAILY Soft
Click here to redirect to my home Click here to redirect to my blog
作者:
2004/7/5 14:11:28
2楼:
把HKEY_CURRENT_USER换成HKEY_LOCAL_MACHINE吧
----------------------------------------------
男儿贵展平生志,为国输忠合天地。甲穿虽则失黄金,剑缺犹能生紫气。塞草萋萋兵士苦,胡虏如今勿胡虏。封侯十万始无心,玉关生入君看取。 敬请光临 学海Delphi站 http://delphi.studysea.net 学海无涯,让我们共同成长!
作者:
2004/7/5 14:23:09
4楼:
多谢两位!
----------------------------------------------
-
作者:
2004/7/5 14:31:04
5楼:
TO:sephil VirtualDrive的意义,以下常量说明放在什么地方,不好意思,真的不会,多谢! const H_RootKey = HKEY_CURRENT_USER; S_KeyName = 'NS VirtualDrive'; S_RunKey = 'Software\Microsoft\Windows\CurrentVersion\Run'; S_AutorunParam = '/Autorun';
----------------------------------------------
-
作者:
sephil (NAILY Soft)
★☆☆☆☆
-
盒子中级会员
2004/7/5 14:41:59
6楼:
const H_RootKey = HKEY_CURRENT_USER; // 要想对所有用户都有效就改成HKEY_LOCAL_MACHINE S_KeyName = 'NS VirtualDrive'; // 键名,可随意修改 S_RunKey = 'Software\Microsoft\Windows\CurrentVersion\Run'; // 自启动键的位置,不要修改 S_AutorunParam = '/Autorun'; // 这是我需要传递给我的程序的参数,你可以不用 WriteString(S_KeyName, ParamStr(0) + ' ' + S_AutorunParam); -> WriteString(S_KeyName, ParamStr(0)); 位置按上面代码的位置就行了
----------------------------------------------
Copyright 2008 ? NAILY Soft
Click here to redirect to my home Click here to redirect to my blog
作者:
2004/7/5 14:44:47
7楼:
放在单元文件的type语句之前或者过程(函数)的var语句之前
----------------------------------------------
男儿贵展平生志,为国输忠合天地。甲穿虽则失黄金,剑缺犹能生紫气。塞草萋萋兵士苦,胡虏如今勿胡虏。封侯十万始无心,玉关生入君看取。 敬请光临 学海Delphi站 http://delphi.studysea.net 学海无涯,让我们共同成长!
作者:
2004/7/5 16:25:41
8楼:
FINISHED,THANK YOU!
----------------------------------------------
-