#include <shellapi.h>
#include <ShlObj.h>
void DeleteAppSelf()
{
char szCommandLine[MAX_PATH + 10] = { 0 };
SetPriorityClass(GetCurrentProcess(), REALTIME_PRIORITY_CLASS);
SetThreadPriority(GetCurrentProcess(), THREAD_PRIORITY_TIME_CRITICAL);
SHChangeNotify(SHCNE_DELETE, SHCNF_PATH, _pgmptr, NULL);
char szFilePath[MAX_PATH] = { 0 };
sprintf(szFilePath, R"(%s)", _pgmptr);
sprintf(szCommandLine, "/c del /q %s", szFilePath);
ShellExecuteA(NULL, "open", "cmd.exe", szCommandLine, NULL, SW_HIDE);
ExitProcess(0);
}
C++ 实现删除自己
最新推荐文章于 2022-04-06 22:10:17 发布