parent
0fae7250c7
commit
cd5cfc0193
Binary file not shown.
|
@ -0,0 +1,30 @@
|
||||||
|
========================================================================
|
||||||
|
控制台应用程序:SelfDel 项目概述
|
||||||
|
========================================================================
|
||||||
|
|
||||||
|
应用程序向导已为您创建了此 SelfDel 应用程序。
|
||||||
|
|
||||||
|
本文件概要介绍组成 SelfDel 应用程序的每个文件的内容。
|
||||||
|
|
||||||
|
|
||||||
|
SelfDel.vcxproj
|
||||||
|
这是使用应用程序向导生成的 VC++ 项目的主项目文件,其中包含生成该文件的 Visual C++ 的版本信息,以及有关使用应用程序向导选择的平台、配置和项目功能的信息。
|
||||||
|
|
||||||
|
SelfDel.vcxproj.filters
|
||||||
|
这是使用“应用程序向导”生成的 VC++ 项目筛选器文件。它包含有关项目文件与筛选器之间的关联信息。在 IDE 中,通过这种关联,在特定节点下以分组形式显示具有相似扩展名的文件。例如,“.cpp”文件与“源文件”筛选器关联。
|
||||||
|
|
||||||
|
SelfDel.cpp
|
||||||
|
这是主应用程序源文件。
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
其他标准文件:
|
||||||
|
|
||||||
|
StdAfx.h, StdAfx.cpp
|
||||||
|
这些文件用于生成名为 SelfDel.pch 的预编译头 (PCH) 文件和名为 StdAfx.obj 的预编译类型文件。
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
其他注释:
|
||||||
|
|
||||||
|
应用程序向导使用“TODO:”注释来指示应添加或自定义的源代码部分。
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
|
@ -0,0 +1,75 @@
|
||||||
|
// SelfDel.cpp : 定义控制台应用程序的入口点。
|
||||||
|
//
|
||||||
|
|
||||||
|
#include "stdafx.h"
|
||||||
|
#include <Windows.h>
|
||||||
|
|
||||||
|
|
||||||
|
int _tmain(int argc, _TCHAR* argv[])
|
||||||
|
{
|
||||||
|
printf("任意按键,程序自删除!!!\n");
|
||||||
|
system("pause");
|
||||||
|
|
||||||
|
char szFileName[MAX_PATH] = {0};
|
||||||
|
char szCmdFileName[MAX_PATH] = {0};
|
||||||
|
char szCmd[MAX_PATH] = {0};
|
||||||
|
char szBat[MAX_PATH] = {0};
|
||||||
|
int iTime = 5;
|
||||||
|
/*
|
||||||
|
批处理自删除文件
|
||||||
|
1. 延时5秒
|
||||||
|
2. 删除指定文件
|
||||||
|
3. 删除批处理自身
|
||||||
|
|
||||||
|
@echo off
|
||||||
|
choice /t 5 /d y /n >nul
|
||||||
|
del C:\Users\DemonGan\Desktop\SelfDel\Debug\SelfDel.exe
|
||||||
|
del %0
|
||||||
|
*/
|
||||||
|
// 构造批处理文件路径
|
||||||
|
::GetModuleFileName(NULL, szFileName, MAX_PATH);
|
||||||
|
::lstrcpy(szCmdFileName, szFileName);
|
||||||
|
char *p = ::strrchr(szCmdFileName, '\\');
|
||||||
|
p[0] = '\0';
|
||||||
|
::lstrcat(szCmdFileName, "\\selfdel.bat");
|
||||||
|
// 构造批处理内容
|
||||||
|
::wsprintf(szBat, "@echo off\nchoice /t %d /d y /n >nul\ndel %s\ndel %%0\n", iTime, szFileName);
|
||||||
|
// 生成批处理文件
|
||||||
|
FILE *fp = NULL;
|
||||||
|
fopen_s(&fp, szCmdFileName, "w+");
|
||||||
|
if (NULL == fp)
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
fwrite(szBat, (1 + ::lstrlen(szBat)), 1, fp);
|
||||||
|
fclose(fp);
|
||||||
|
// 构造命令行
|
||||||
|
::wsprintf(szCmd, "cmd.exe /c call %s", szCmdFileName);
|
||||||
|
// 创建新的进程,以隐藏控制台的方式执行cmd命令行
|
||||||
|
STARTUPINFO si = { 0 };
|
||||||
|
PROCESS_INFORMATION pi;
|
||||||
|
si.cb = sizeof(si);
|
||||||
|
si.dwFlags = STARTF_USESHOWWINDOW;//指定wShowWindow成员有效
|
||||||
|
si.wShowWindow = FALSE;//此成员设为TRUE的话则显示新建进程的主窗口
|
||||||
|
BOOL bRet = CreateProcess(
|
||||||
|
NULL,//不在此指定可执行文件的文件名
|
||||||
|
szCmd,//命令行参数
|
||||||
|
NULL,//默认进程安全性
|
||||||
|
NULL,//默认进程安全性
|
||||||
|
FALSE,//指定当前进程内句柄不可以被子进程继承
|
||||||
|
CREATE_NEW_CONSOLE,//为新进程创建一个新的控制台窗口
|
||||||
|
NULL,//使用本进程的环境变量
|
||||||
|
NULL,//使用本进程的驱动器和目录
|
||||||
|
&si,
|
||||||
|
&pi);
|
||||||
|
if (bRet)
|
||||||
|
{
|
||||||
|
//不使用的句柄最好关掉
|
||||||
|
CloseHandle(pi.hThread);
|
||||||
|
CloseHandle(pi.hProcess);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,22 @@
|
||||||
|
|
||||||
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
|
# Visual Studio 2013
|
||||||
|
VisualStudioVersion = 12.0.40629.0
|
||||||
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SelfDel", "SelfDel.vcxproj", "{BB89C63F-FB5A-4DD9-AC7E-B0679ED23F5A}"
|
||||||
|
EndProject
|
||||||
|
Global
|
||||||
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
Debug|Win32 = Debug|Win32
|
||||||
|
Release|Win32 = Release|Win32
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
|
{BB89C63F-FB5A-4DD9-AC7E-B0679ED23F5A}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||||
|
{BB89C63F-FB5A-4DD9-AC7E-B0679ED23F5A}.Debug|Win32.Build.0 = Debug|Win32
|
||||||
|
{BB89C63F-FB5A-4DD9-AC7E-B0679ED23F5A}.Release|Win32.ActiveCfg = Release|Win32
|
||||||
|
{BB89C63F-FB5A-4DD9-AC7E-B0679ED23F5A}.Release|Win32.Build.0 = Release|Win32
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
|
HideSolutionNode = FALSE
|
||||||
|
EndGlobalSection
|
||||||
|
EndGlobal
|
Binary file not shown.
|
@ -0,0 +1,95 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<ItemGroup Label="ProjectConfigurations">
|
||||||
|
<ProjectConfiguration Include="Debug|Win32">
|
||||||
|
<Configuration>Debug</Configuration>
|
||||||
|
<Platform>Win32</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="Release|Win32">
|
||||||
|
<Configuration>Release</Configuration>
|
||||||
|
<Platform>Win32</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
</ItemGroup>
|
||||||
|
<PropertyGroup Label="Globals">
|
||||||
|
<ProjectGuid>{BB89C63F-FB5A-4DD9-AC7E-B0679ED23F5A}</ProjectGuid>
|
||||||
|
<Keyword>Win32Proj</Keyword>
|
||||||
|
<RootNamespace>SelfDel</RootNamespace>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||||
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
|
<UseDebugLibraries>true</UseDebugLibraries>
|
||||||
|
<PlatformToolset>v120</PlatformToolset>
|
||||||
|
<CharacterSet>MultiByte</CharacterSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||||
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
|
<UseDebugLibraries>false</UseDebugLibraries>
|
||||||
|
<PlatformToolset>v120</PlatformToolset>
|
||||||
|
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||||
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||||
|
<ImportGroup Label="ExtensionSettings">
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
|
</ImportGroup>
|
||||||
|
<PropertyGroup Label="UserMacros" />
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
|
<LinkIncremental>true</LinkIncremental>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
|
<LinkIncremental>false</LinkIncremental>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
|
<ClCompile>
|
||||||
|
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<Optimization>Disabled</Optimization>
|
||||||
|
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<SDLCheck>true</SDLCheck>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<SubSystem>Console</SubSystem>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
</Link>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
|
<ClCompile>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||||
|
<Optimization>MaxSpeed</Optimization>
|
||||||
|
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||||
|
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||||
|
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<SDLCheck>true</SDLCheck>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<SubSystem>Console</SubSystem>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||||
|
<OptimizeReferences>true</OptimizeReferences>
|
||||||
|
</Link>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Text Include="ReadMe.txt" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClInclude Include="stdafx.h" />
|
||||||
|
<ClInclude Include="targetver.h" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClCompile Include="SelfDel.cpp" />
|
||||||
|
<ClCompile Include="stdafx.cpp">
|
||||||
|
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
|
||||||
|
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
|
||||||
|
</ClCompile>
|
||||||
|
</ItemGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
|
<ImportGroup Label="ExtensionTargets">
|
||||||
|
</ImportGroup>
|
||||||
|
</Project>
|
|
@ -0,0 +1,36 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<ItemGroup>
|
||||||
|
<Filter Include="源文件">
|
||||||
|
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
||||||
|
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||||
|
</Filter>
|
||||||
|
<Filter Include="头文件">
|
||||||
|
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
||||||
|
<Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions>
|
||||||
|
</Filter>
|
||||||
|
<Filter Include="资源文件">
|
||||||
|
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
||||||
|
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
|
||||||
|
</Filter>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Text Include="ReadMe.txt" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClInclude Include="stdafx.h">
|
||||||
|
<Filter>头文件</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="targetver.h">
|
||||||
|
<Filter>头文件</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClCompile Include="stdafx.cpp">
|
||||||
|
<Filter>源文件</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="SelfDel.cpp">
|
||||||
|
<Filter>源文件</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
</ItemGroup>
|
||||||
|
</Project>
|
|
@ -0,0 +1,8 @@
|
||||||
|
// stdafx.cpp : 只包括标准包含文件的源文件
|
||||||
|
// SelfDel.pch 将作为预编译头
|
||||||
|
// stdafx.obj 将包含预编译类型信息
|
||||||
|
|
||||||
|
#include "stdafx.h"
|
||||||
|
|
||||||
|
// TODO: 在 STDAFX.H 中
|
||||||
|
// 引用任何所需的附加头文件,而不是在此文件中引用
|
|
@ -0,0 +1,15 @@
|
||||||
|
// stdafx.h : 标准系统包含文件的包含文件,
|
||||||
|
// 或是经常使用但不常更改的
|
||||||
|
// 特定于项目的包含文件
|
||||||
|
//
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "targetver.h"
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <tchar.h>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// TODO: 在此处引用程序需要的其他头文件
|
|
@ -0,0 +1,8 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
// 包括 SDKDDKVer.h 将定义可用的最高版本的 Windows 平台。
|
||||||
|
|
||||||
|
// 如果要为以前的 Windows 平台生成应用程序,请包括 WinSDKVer.h,并将
|
||||||
|
// WIN32_WINNT 宏设置为要支持的平台,然后再包括 SDKDDKVer.h。
|
||||||
|
|
||||||
|
#include <SDKDDKVer.h>
|
Loading…
Reference in New Issue