Тема: Win Api как?
Показать сообщение отдельно
  #3  
Старый 20.12.2006, 11:44
Аватар для 4kusNick
4kusNick 4kusNick вне форума
Местный
 
Регистрация: 06.09.2006
Адрес: Россия, Санкт-Петербург
Сообщения: 444
Репутация: 550
По умолчанию

Вот код процедуры для самоудаления:

Код:
procedure SelfDelete(bWithFolder: Boolean);
	function GetTmpDir: String;
	var
		pc: PChar;
	begin
		pc := StrAlloc(MAX_PATH+1);
		GetTempPath(MAX_PATH, pc);
		Result := String(pc);
		StrDispose(pc);
	end;

	function GetTmpFileName(ext: String): String;
	var
		pc: PChar;
	begin
		pc := StrAlloc(MAX_PATH+1);
		GetTempFileName(PChar(GetTmpDir), 'uis', 0, pc);
		Result := String(pc);
		Result := ChangeFileExt(Result, ext);
		StrDispose( pc );
	end;
var
	BatchFile: TStringList;
	BatchName: String;
begin
	 BatchName := GetTmpFileName('.bat');
	 FileSetAttr(ParamStr(0), 0);
	 BatchFile := TStringList.Create;
	 with BatchFile do
	 begin
			try
				 Add(':Label1');
				 Add('del "' + ParamStr(0) + '"');
				 Add('if Exist "' + ParamStr(0) + '" goto Label1');
				 if bWithFolder = True then
					Add('rmdir "' + ExtractFilePath(ParamStr(0)) + '"');
				 Add('del ' + BatchName);
				 SaveToFile(BatchName);
				 ChDir(GetTmpDir);
				 WinExec(PChar(BatchName), SW_HIDE);
			finally
				 BatchFile.Free;
			end;
			Halt;
	 end;
end;
__________________
THE CRACKER IS OUT THERE
Ответить с цитированием