⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 deletifdlg.cpp

📁 从压缩包内删除TIF,请大家多多支持呀
💻 CPP
字号:
// DeleTifDlg.cpp : implementation file
//

#include "stdafx.h"
#include "DeleTif.h"
#include "DeleTifDlg.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// 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:
	//{{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)
		// No message handlers
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CDeleTifDlg dialog

CDeleTifDlg::CDeleTifDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CDeleTifDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CDeleTifDlg)
	m_Path = _T("");
	//}}AFX_DATA_INIT
	// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
	m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}

void CDeleTifDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CDeleTifDlg)
	DDX_Control(pDX, IDC_PROGRESS1, m_Progress);
	DDX_Text(pDX, IDC_EDIT1, m_Path);
	//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CDeleTifDlg, CDialog)
	//{{AFX_MSG_MAP(CDeleTifDlg)
	ON_WM_SYSCOMMAND()
	ON_WM_PAINT()
	ON_WM_QUERYDRAGICON()
	ON_BN_CLICKED(IDC_BUTTON1, OnBrow)
	ON_BN_CLICKED(IDC_BUTTON2, OnOk)
	ON_BN_CLICKED(IDC_BUTTON3, OnExit)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CDeleTifDlg message handlers

BOOL CDeleTifDlg::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
	
	return TRUE;  // return TRUE  unless you set the focus to a control
}

void CDeleTifDlg::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 CDeleTifDlg::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 CDeleTifDlg::OnQueryDragIcon()
{
	return (HCURSOR) m_hIcon;
}

void CDeleTifDlg::OnBrow() 
{
	// TODO: Add your control notification handler code here
	BROWSEINFO bi;
	char dispname[MAX_PATH],path[MAX_PATH];
	ITEMIDLIST *pidl;
	//
	bi.hwndOwner=m_hWnd;
	bi.pidlRoot=0;
	bi.pszDisplayName=dispname;
	bi.lpszTitle="请选择查找目录:";
	bi.ulFlags=BIF_RETURNONLYFSDIRS|BIF_EDITBOX|BIF_DONTGOBELOWDOMAIN ;
	bi.lpfn=0;
	bi.lParam=0;
	bi.iImage=0;
	if(pidl=SHBrowseForFolder(&bi))
	{
		SHGetPathFromIDList(pidl,path);
        m_Path=CString(path);
		UpdateData(false);
	}
}

void CDeleTifDlg::Search(CString cPath1)
{
	CString Fn,FnName,FnPath,cCmdLine,cExc;
	cExc="*.Rar";                  //搜文件下的扩展文件名为

	CFileFind FileFind,FileFind1;
	BOOL bWorking=FileFind.FindFile(cPath1+"\\"+cExc);
	while (bWorking)
	{
		bWorking = FileFind.FindNextFile();
		Fn=FileFind.GetFileName();
		FnName=FileFind.GetFilePath();
        //cCmdLine="C:\\456\\rar.exe d "+FnName+" *.tif";
		cCmdLine=" d "+FnName+" *.tif";
		CArrayFn.Add(cCmdLine);
	}
	FileFind.Close();
}

void CDeleTifDlg::OnOk() 
{
	// TODO: Add your control notification handler code here
	this->UpdateData();
	if (!m_Path.IsEmpty())
	{
		SearchDir(m_Path);
		CString cCmdLine;
		int nCount=CArrayFn.GetSize();
		m_Progress.SetRange(0,nCount-1);
		
		for (int n=0;n<nCount;n++)
		{
			cCmdLine=CArrayFn.GetAt(n);
			m_Progress.SetPos(n);
			Exe(cCmdLine);

		}
		AfxMessageBox("从压缩包内删除文件完毕!");
	}
}

void CDeleTifDlg::Exe(CString cCmdLine)
{
	char *buff=new char[256];
	strcpy(buff,cCmdLine);  //FilePath为你调用的程序的绝对路径

	SHELLEXECUTEINFO  ExeInfo;

	ZeroMemory(&ExeInfo,sizeof(SHELLEXECUTEINFO));
	ExeInfo.cbSize   =   sizeof(SHELLEXECUTEINFO);
	ExeInfo.lpParameters =buff;
	ExeInfo.lpFile   =   "rar.exe";
	ExeInfo.fMask   =   SEE_MASK_NOCLOSEPROCESS;
	ExeInfo.nShow   =   SW_HIDE;//SW_HIDE;
	ShellExecuteEx(&ExeInfo);
	delete   []buff;
	
	WaitForSingleObject(ExeInfo.hProcess,INFINITE);//等待ShellExecute调用的程序执行完成。


}

void CDeleTifDlg::OnExit() 
{
	// TODO: Add your control notification handler code here
	this->DestroyWindow();
}

void CDeleTifDlg::SearchDir(CString str)
{
	CString Fn;
	Search(str);

	CFileFind FileFind,FileFind1;
	BOOL bWorking=FileFind.FindFile(str+"\\*.*");
	while (bWorking)
	{
		bWorking = FileFind.FindNextFile();
		if (FileFind.IsDirectory()&&!FileFind.IsDots())
		{
		   Fn=str+"\\"+FileFind.GetFileName();
		   SearchDir(Fn);
		}
	}
	FileFind.Close();
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -