【源码】VS2010清理助手

#include <Windows.h>
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <Shlwapi.h>
using namespace std;

#pragma comment(lib,"Shlwapi.lib")

void FileDelete(char* directory)
{
	SHFILEOPSTRUCT shFileOp;
	memset(&shFileOp,0,sizeof(shFileOp));
	char temp[MAX_PATH]={0};
	strcpy(temp,directory);

	shFileOp.wFunc= FO_DELETE;
	shFileOp.pFrom= temp;
	shFileOp.pTo= NULL;
	shFileOp.fFlags= FOF_SILENT | FOF_NOCONFIRMATION | FOF_NOCONFIRMMKDIR;
	if(0==SHFileOperation(&shFileOp))
		cout<<directory<<"     已删除"<<endl;
}

void find(char *lpPath)
{
	string strFile;
	int  pos;
	string  strFileExt;
	char szFind[MAX_PATH];
	char szFile[MAX_PATH];
	char szDelePath[MAX_PATH];
	WIN32_FIND_DATAA FindFileData;
	strcpy(szFind,lpPath);
	strcat(szFind,"*.*");
	HANDLE hFind=::FindFirstFileA(szFind,&FindFileData);
	if(INVALID_HANDLE_VALUE == hFind)
		return;
	while(TRUE)
	{
		if(FindFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
		{
			if(FindFileData.cFileName[0]!='.')
			{
				if(strcmp(FindFileData.cFileName,"ipch")==0)
				{
					sprintf(szDelePath,"%sipch",lpPath);
					FileDelete(szDelePath);
				}else if(strcmp(FindFileData.cFileName,"Debug")==0)
				{
					sprintf(szDelePath,"%sDebug",lpPath);
					FileDelete(szDelePath);
				}else if(strcmp(FindFileData.cFileName,"Release")==0)
				{
					sprintf(szDelePath,"%sRelease",lpPath);
					FileDelete(szDelePath);
				}
					//cout<<lpPath<<endl;
				strcpy(szFile,lpPath);
				strcat(szFile,"\\");
				strcat(szFile,FindFileData.cFileName);
				strcat(szFile,"\\");
				find(szFile);
			}
		}
		else
		{
			strFile=FindFileData.cFileName;
			pos=strFile.find_last_of('.');
			if(pos>0)
				strFileExt=strFile.substr(pos+1);
			if(strcmp("sdf",strlwr((char*)strFileExt.c_str()))==0)
			{
				strcpy(szFile,lpPath);
				strcat(szFile,"\\");
				strcat(szFile,FindFileData.cFileName);
				FileDelete(szFile);
				//cout<<FindFileData.cFileName<<"   已删除"<<endl;
			}
		}
		if(!FindNextFile(hFind,&FindFileData))
			break;
	}
	FindClose(hFind);
}
int main()
{
	cout<<"************************************"<<endl;
	cout<<"************************************"<<endl;
	cout<<"---------->VS2010清理助手<----------"<<endl;
	cout<<"************************************"<<endl;
	cout<<"注意:程序会删除你所输入目录下所有.sdf文件"<<endl;
	cout<<"以及名为Debug、Release、ipch文件夹"<<endl;
	cout<<"使用本程序所造成的一切后果,请使用者承担"<<endl;
	cout<<"                   By L0g1n  2012.8.4晚"<<endl;
	cout<<"************************************"<<endl;
	cout<<"请输入文件夹:(如E盘下所有文件E:\\)"<<endl;
	char szInput[MAX_PATH];
	cin>>szInput;
	find(szInput);
	system("pause");
	return 0;
}

注:程序在使用管理员权限,否则删不掉。

今天清理了一下,瞬间多了30多个G,很好,很强大啊。

源码下载

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值