// DiskCleanDlg.cpp : implementation file
//
#include "stdafx.h"
#include "DiskClean.h"
#include "DiskCleanDlg.h"
//#include "SystemInfo.h"
//#include "DiskSerial.h"
#include <dos.h>
#include <direct.h>
//#include "Product.h"
#include "SelectFile.h"
#include <afxmt.h>
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
DWORD g_dWSel;
CDiskCleanDlg* gpMainWnd;
CString gPath,gPath1;
BOOL gbRuning=FALSE;
#define WM_MYEXIT WM_USER + 1
#define WM_ANSWER WM_USER + 2
UINT ThreadsProc(LPVOID pParam) ;
HANDLE ghThreadExitEvent;
void DealRabbishScan(CString path);
void DeleteRabbishFile(CString FilePath,CString FileName);
void DeleteZeroFile(CString path);
/////////////////////////////////////////////////////////////////////////////
// CAboutDlg dialog used for App About
class CAboutDlg : public CDialog
{
public:
CAboutDlg();
// Dialog Data
//{{AFX_DATA(CAboutDlg)
enum { IDD = IDD_ABOUTBOX };
//}}AFX_DATA
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CAboutDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
virtual BOOL OnInitDialog();
//{{AFX_MSG(CAboutDlg)
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
//{{AFX_DATA_INIT(CAboutDlg)
//}}AFX_DATA_INIT
}
void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CAboutDlg)
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
//{{AFX_MSG_MAP(CAboutDlg)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CDiskCleanDlg dialog
CDiskCleanDlg::CDiskCleanDlg(CWnd* pParent /*=NULL*/)
: CDialog(CDiskCleanDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CDiskCleanDlg)
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
m_nDrvCount=0;
g_dWSel=0xFFFFFFFF;
gpMainWnd=this;
//
//
ghThreadExitEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
}
void CDiskCleanDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CDiskCleanDlg)
DDX_Control(pDX, IDC_LIST2, m_ctlListFile1);
DDX_Control(pDX, IDC_LIST1, m_ctlListFile);
DDX_Control(pDX, IDC_COMBO_DRIVE, m_ctlComboDrive);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CDiskCleanDlg, CDialog)
//{{AFX_MSG_MAP(CDiskCleanDlg)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_BN_CLICKED(IDC_SELECT, OnSelect)
ON_BN_CLICKED(ID_APP_ABOUT, OnAppAbout)
ON_BN_CLICKED(IDC_START, OnStart)
ON_BN_CLICKED(IDC_STOP, OnStop)
//}}AFX_MSG_MAP
ON_MESSAGE(WM_MYEXIT,OnExit)
ON_MESSAGE(WM_ANSWER,OnAnswer)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CDiskCleanDlg message handlers
BOOL CDiskCleanDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// Add "About..." menu item to system menu.
// IDM_ABOUTBOX must be in the system command range.
ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
ASSERT(IDM_ABOUTBOX < 0xF000);
CMenu* pSysMenu = GetSystemMenu(FALSE);
if (pSysMenu != NULL)
{
CString strAboutMenu;
strAboutMenu.LoadString(IDS_ABOUTBOX);
if (!strAboutMenu.IsEmpty())
{
pSysMenu->AppendMenu(MF_SEPARATOR);
pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
}
}
// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
// TODO: Add extra initialization here
GetSysDriver();
m_ctlComboDrive.SetCurSel(0);
//for(int i=0;i<26;i++)
//
return TRUE; // return TRUE unless you set the focus to a control
}
void CDiskCleanDlg::OnSysCommand(UINT nID, LPARAM lParam)
{
if ((nID & 0xFFF0) == IDM_ABOUTBOX)
{
CAboutDlg dlgAbout;
dlgAbout.DoModal();
}
else
{
CDialog::OnSysCommand(nID, lParam);
}
}
// If you add a minimize button to your dialog, you will need the code below
// to draw the icon. For MFC applications using the document/view model,
// this is automatically done for you by the framework.
void CDiskCleanDlg::OnPaint()
{
if (IsIconic())
{
CPaintDC dc(this); // device context for painting
SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
// Center icon in client rectangle
int cxIcon = GetSystemMetrics(SM_CXICON);
int cyIcon = GetSystemMetrics(SM_CYICON);
CRect rect;
GetClientRect(&rect);
int x = (rect.Width() - cxIcon + 1) / 2;
int y = (rect.Height() - cyIcon + 1) / 2;
// Draw the icon
dc.DrawIcon(x, y, m_hIcon);
}
else
{
CDialog::OnPaint();
}
}
// The system calls this to obtain the cursor to display while the user drags
// the minimized window.
HCURSOR CDiskCleanDlg::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}
//得到硬盘驱动器盘符
void CDiskCleanDlg::GetSysDriver()
{
UINT drvType=0;
CString drv;
char ch;
for(ch='C';drvType!=1;ch++){
drv="X:\\";
drv.SetAt(0,ch);
drvType=GetDriveType(drv);
if(drvType==DRIVE_FIXED){
m_ctlComboDrive.AddString(drv);
}
}
}
//垃圾文件扫描
void DealRabbishScan(CString path)
{
if(!gbRuning)return;
chdir(path); //更换当前目录
gPath1=path;
::SendMessage(gpMainWnd->m_hWnd ,WM_ANSWER, (WPARAM)2, (LPARAM)0);
if(g_dWSel & 0x1)DeleteRabbishFile(path,"*.~*");
if(g_dWSel & 0x2)DeleteRabbishFile(path,"*.ALT");
if(g_dWSel & 0x4)DeleteRabbishFile(path,"*.FIX");
if(g_dWSel & 0x8)DeleteRabbishFile(path,"*.PRV");
if(g_dWSel & 0x10)DeleteRabbishFile(path,"*.SYD");
if(g_dWSel & 0x20)DeleteRabbishFile(path,"*.$$$");
if(g_dWSel & 0x40)DeleteRabbishFile(path,"*.CLN");
if(g_dWSel & 0x80)DeleteRabbishFile(path,"*.GID");
if(g_dWSel & 0x100)DeleteRabbishFile(path,"*.SAV");
if(g_dWSel & 0x200)DeleteRabbishFile(path,"*.tmp");
if(g_dWSel & 0x400)DeleteRabbishFile(path,"*.?~?");
if(g_dWSel & 0x800)DeleteRabbishFile(path,"*.CYP");
if(g_dWSel & 0x1000)DeleteRabbishFile(path,"*.LOO");
if(g_dWSel & 0x2000)DeleteRabbishFile(path,"*.SCO");
if(g_dWSel & 0x4000)DeleteRabbishFile(path,"*.UMB");
if(g_dWSel & 0x8000)DeleteRabbishFile(path,"*.B?K");
if(g_dWSel & 0x10000)DeleteRabbishFile(path,"*.ERR");
if(g_dWSel & 0x20000)DeleteRabbishFile(path,"*.OLD");
if(g_dWSel & 0x40000)DeleteRabbishFile(path,"*.SLK");
if(g_dWSel & 0x80000)DeleteRabbishFile(path,"*.UBK");
if(g_dWSel & 0x100000)DeleteRabbishFile(path,"*.00?");
if(g_dWSel & 0x200000)DeleteRabbishFile(path,"*.ffa");
if(g_dWSel & 0x400000)DeleteRabbishFile(path,"*.ffo");
if(g_dWSel & 0x800000)DeleteRabbishFile(path,"*.ffl");
if(g_dWSel & 0x1000000)DeleteRabbishFile(path,"*.T");
if(g_dWSel & 0x2000000)DeleteRabbishFile(path,"*.ffx");
//删除单个文件
if(g_dWSel & 0x4000000)DeleteRabbishFile(path,"desktop.ini");
if(g_dWSel & 0x8000000)DeleteRabbishFile(path,"folder.htt");
//
DeleteZeroFile(path);
BOOL flag;
CFileFind m_File;
DWORD dwRes;
flag=m_File.FindFile(NULL);
while(flag && gbRuning){
dwRes=WaitForSingleObject(ghThreadExitEvent,0);
if(dwRes==WAIT_OBJECT_0){
gbRuning=FALSE;
break;
}
flag=m_File.FindNextFile();
if(m_File.IsDirectory()){
if(!m_File.IsDots()){
path=m_File.GetFilePath();
//DeleteZeroFile(path);
DealRabbishScan(path);
}
}
}
}
//删除垃圾文件
void DeleteRabbishFile(CString FilePath,CString FileName)
{
//((CListBox*)gpMainWnd->GetDlgItem(IDC_LIST1))->AddString(FilePath);
CFileFind findfile;
CString tFileName;
CString Path;
LV_ITEM lvitem;
lvitem.mask = LVIF_TEXT;
//
SetCurrentDirectory(FilePath) ;
if(findfile.FindFile(FileName)){
while(findf
没有合适的资源?快使用搜索试试~ 我知道了~
商业编程-源码-垃圾文件清除器源代码.zip
共15个文件
h:5个
cpp:4个
ico:1个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 136 浏览量
2022-06-23
06:41:49
上传
评论
收藏 17KB ZIP 举报
温馨提示
商业编程-源码-垃圾文件清除器源代码.zip
资源推荐
资源详情
资源评论
收起资源包目录
商业编程-源码-垃圾文件清除器源代码.zip (15个子文件)
垃圾文件清除器源代码
DiskClean
SelectFile.cpp 3KB
StdAfx.cpp 211B
DiskClean.dsw 543B
resource.h 3KB
DiskCleanDlg.cpp 11KB
DiskClean.rc 10KB
DiskClean.clw 3KB
DiskCleanDlg.h 2KB
StdAfx.h 1KB
SelectFile.h 1KB
DiskClean.cpp 2KB
DiskClean.dsp 5KB
res
DiskClean.rc2 401B
DiskClean.ico 1KB
DiskClean.h 1KB
共 15 条
- 1
资源评论
programxh
- 粉丝: 17
- 资源: 1万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功