vc 自删除
// delself.cpp : 定义控制台应用程序的入口点。
//
#include "stdafx.h"
#include <windows.h>
#include <stdio.h>
BOOL SelfDelete()
{
char szFile[MAX_PATH], szCmd[MAX_PATH];
if((GetModuleFileNameA(0,szFile,MAX_PATH)!=0) &&
(GetShortPathNameA(szFile,szFile,MAX_PATH)!=0))
{
strcpy(szCmd,"/c del ");
strcat(szCmd,szFile);
strcat(szCmd," >> NUL");
if((GetEnvironmentVariableA("ComSpec",szFile,MAX_PATH)!=0) &&
((INT)ShellExecuteA(0,0,szFile,szCmd,0,SW_HIDE)>32))
return TRUE;
}
return FALSE;
}
int WINAPI WinMain( __in HINSTANCE hInstance, __in_opt HINSTANCE hPrevInstance, __in LPSTR lpCmdLine, __in int nShowCmd )
{
SelfDelete();
return 0;
}