65,187
社区成员




#include <tchar.h>
#include <objbase.h>
//实现程序自删除
BOOL SelfDel(BOOL bExit = TRUE)
{
char SelfPath[MAX_PATH];
char Command[2048];
char BatName[] = "__fdfads329gke2f4bfnthg_del__.bat";
::GetModuleFileNameA(NULL, SelfPath, MAX_PATH);
::lstrcpyA(Command, "@echo off\n\r");
for(int i=0;i<10;i++)
::lstrcatA(Command, "@echo asdfhdsafjkahlsdjfhlk>>3596799a1543bc9f.aqq\n\r");
::lstrcatA(Command, "@del 3596799a1543bc9f.aqq\n\r");
::lstrcatA(Command, "@del \"");
::lstrcatA(Command, SelfPath);
::lstrcatA(Command, "\"\n\r");
::lstrcatA(Command, "@del ");
::lstrcatA(Command, BatName);
::lstrcatA(Command, "\n\r@exit");
HANDLE hFile = ::CreateFileA(BatName, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0);
if(hFile == INVALID_HANDLE_VALUE)
return FALSE;
DWORD dwWritten;
if(!::WriteFile(hFile, Command, ::lstrlenA(Command), &dwWritten, NULL))
return FALSE;
::CloseHandle(hFile);
if(::WinExec(BatName, SW_HIDE) <= 31)
return FALSE;
if(bExit)
::ExitProcess(0);
return TRUE;
}