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

📄 page2.cpp

📁 一个对系统执行文件提供方便管理的软件,里面用到的技术值得参考.
💻 CPP
字号:
// Page2.cpp : implementation file
//

#include "stdafx.h"
#include "PStart.h"
#include "Page2.h"

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

/////////////////////////////////////////////////////////////////////////////
// CPage2 dialog


CPage2::CPage2(CWnd* pParent /*=NULL*/)
	: CDialog(CPage2::IDD, pParent)
{
	//{{AFX_DATA_INIT(CPage2)
		// NOTE: the ClassWizard will add member initialization here
	//}}AFX_DATA_INIT
}


void CPage2::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CPage2)
	DDX_Control(pDX, IDC_TREE, m_tree);
	DDX_Control(pDX, IDC_EDIT1, m_edit);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CPage2, CDialog)
	//{{AFX_MSG_MAP(CPage2)
	ON_EN_CHANGE(IDC_EDIT1, OnExecuteSearch)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CPage2 message handlers

BOOL CPage2::OnInitDialog()
{
	CDialog::OnInitDialog();

	m_menu.LoadMenu(IDR_PAGE2MENU);
	ASSERT(m_menu);
    
	return TRUE;
}


HRESULT CPage2::WindowProc(UINT message, WPARAM wparam, LPARAM lparam)
{
     switch(message)
	 {
	   case WM_COMMAND:
		   switch(LOWORD(wparam))
		   {
		    case ID_PAGE2MENURUN:
                 MenuRun();
				 break;
			case ID_PAGE2MENUOPEN:
                 MenuOpenContainingFile();
				 break;

		   }

	}

	 return(CDialog::WindowProc(message, wparam, lparam));

}


void CPage2::MenuRun()
{
    ShellExecute(NULL, _T("open"), m_FilePath, NULL, NULL, SW_SHOW);  

}


void CPage2::MenuOpenContainingFile()
{  
    CString FilePath,cstr;
	int pos;

	pos=m_FilePath.GetLength()-1; 
	cstr="\\";
	while(pos>0)
	{  	   
       if(m_FilePath.GetAt(pos)==cstr)
	   {   
		   FilePath=m_FilePath.Left(pos);
		   break;
	   }
	   pos--;
	}

   ShellExecute(NULL, _T("open"), FilePath, NULL, NULL, SW_SHOW);

}


void CPage2::OnExecuteSearch() 
{
	// TODO: If this is a RICHEDIT control, the control will not
	// send this notification unless you override the CDialog::OnInitDialog()
	// function and call CRichEditCtrl().SetEventMask()
	// with the ENM_CHANGE flag ORed into the mask.
	
	// TODO: Add your control notification handler code here
	 
	 char *path;
	 DWORD threadid;

	 path="c:";

     UpdateData(TRUE);
	 m_edit.GetWindowText(m_searchinfo);
	 
//	 HANDLE hthread=CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)&FindFile, (LPVOID)&path, 0, &threadid);

}



void FindFile(LPVOID lparam)
{  
   char *path, szFile[MAX_PATH], szFileName[30];
   int len;
   CString FileExt, FileName, SearchInfo, cstr;
   WIN32_FIND_DATA FindData ;
   HANDLE hFind;
   CPage2 *page2;

   path=(char*)lparam;
   page2=(CPage2*)AfxGetApp()->m_pMainWnd;
   ASSERT(page2);
   
   len=page2->m_searchinfo.GetLength();
   SearchInfo=page2->m_searchinfo;

   lstrcpy(szFile, path);
   lstrcat(szFile, "\\*");

   hFind= FindFirstFile(szFile, &FindData );

   if(hFind==INVALID_HANDLE_VALUE)
   	  return;
   
    while(TRUE)
	{
		if(FindData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
		{  
		   if(FindData.cFileName[0]!='.')
		   {
		     lstrcpy(szFile, path);
		     lstrcat(szFile, "\\"); 
             lstrcat(szFile, FindData.cFileName);		

		     FindFile(szFile);

		   }

        }

		else
		{   
			FileName=szFile;
            FileExt=FileName.Right(5);
			
			if(FileExt=="*.exe")
			{
               /*匹配字符串*/
			   for(int pos=0; pos<FileName.GetLength()-len; pos++)
			   {
                 cstr=FileName.Mid(pos, len);
				 if(lstrcmp(cstr, SearchInfo)==0)
				 {
				    	 
				 }

			   }//for
                
			}

		}//else

        if(!FindNextFile(hFind, &FindData))
			break;
	}//while

	   FindClose(hFind);
}

⌨️ 快捷键说明

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