利用环境变量自删除
void DeleteMyself()
{
TCHAR szFile[MAX_PATH], szCmd[MAX_PATH];
if ((GetModuleFileName(0, szFile, MAX_PATH) != 0) &&
(GetShortPathName(szFile, szFile, MAX_PATH) != 0))
{
lstrcpy(szCmd, TEXT("/c del "));
lstrcat(szCmd, szFile);
lstrcat(szCmd, TEXT(" >> NUL"));
if ((GetEnvironmentVariable(TEXT("ComSpec"), szFile, MAX_PATH) != 0) &&
((INT)ShellExecute(0, 0, szFile, szCmd, 0, SW_HIDE) > 32))
return ;
}
return ;
}