?? getcodedlg.cpp
字號(hào):
// GetCodeDlg.cpp : implementation file
//
#include "stdafx.h"
#include "GetCode.h"
#include "GetCodeDlg.h"
#include "stdlib.h"
#include "ctype.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
#define INPUTDIALOGID 1001
#define INPUTRETRYDIALOGID 1002
#define MAX_THREAD 50
/////////////////////////////////////////////////////////////////////////////
// CGetCodeDlg dialog
struct ThreadStru
{CWinThread * pThread;
}m_pEnumThread[MAX_THREAD];
BOOL m_bEnum;
HWND m_hwnd;
HWND hButton1,hButton2;
BOOL m_bPasswordStyle;
bool bFetched;
UINT nThreadCount;
char lpszDialogCaption[80];
char lpszButtonConfirmCaption[20];
char lpszDialogRetryCaption[80];
char lpszButtonRetryCaption[20];
char lpszThreadCount[4];
char lpszPath[MAX_PATH];
char lpszMethod[30]="\0";
HANDLE m_hMutex;
TCHAR lpszPassword[30];
DWORD WINAPI EnumProc( LPVOID );
BOOL CALLBACK EnumWindowsProc(HWND hwnd,LPARAM lParam );
BOOL CALLBACK EnumChildProc(HWND hwnd, LPARAM lParam);
void EnumPasswordString(void);
CGetCodeDlg::CGetCodeDlg(CWnd* pParent /*=NULL*/)
: CDialog(CGetCodeDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CGetCodeDlg)
m_nThreadCount = 0;
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_bPasswordStyle=FALSE;
m_bEnum=TRUE;
bFetched=true;
m_hwnd=this->m_hWnd;
GetPrivateProfileString("設(shè)置","線程計(jì)數(shù)","1",lpszThreadCount,4,"Setup.ini");
GetPrivateProfileString("設(shè)置","口令輸入窗口標(biāo)題","LOGIN",lpszDialogCaption,80,"Setup.ini");
GetPrivateProfileString("設(shè)置","口令輸入窗口確認(rèn)按鈕標(biāo)題","OK",lpszButtonConfirmCaption,20,"Setup.ini");
GetPrivateProfileString("設(shè)置","提示口令錯(cuò)要求重新輸入窗口標(biāo)題","Login",lpszDialogRetryCaption,80,"Setup.ini");
GetPrivateProfileString("設(shè)置","提示口令錯(cuò)要求重新輸入窗口確認(rèn)按鈕標(biāo)題","確認(rèn)",lpszButtonRetryCaption,20,"Setup.ini");
GetPrivateProfileString("設(shè)置","窮舉方法","數(shù)字",lpszMethod,30,"Setup.ini");
GetPrivateProfileString("設(shè)置","窮舉文件","",lpszPath,MAX_PATH,"Setup.ini");
this->m_nThreadCount=atoi(lpszThreadCount);
nThreadCount=this->m_nThreadCount;
m_hIcon= AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
void CGetCodeDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CGetCodeDlg)
DDX_Control(pDX, IDCANCEL, m_Quit);
DDX_Control(pDX, IDC_EDIT6, m_EditPath);
DDX_Control(pDX, IDC_BROWSE, m_BtnBrowser);
DDX_Control(pDX, IDPause, m_Pause);
DDX_Control(pDX, IDOK, m_OK);
DDX_Text(pDX, IDC_EDIT5, m_nThreadCount);
DDV_MinMaxUInt(pDX, m_nThreadCount, 1, 50);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CGetCodeDlg, CDialog)
//{{AFX_MSG_MAP(CGetCodeDlg)
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_BN_CLICKED(IDCANCEL, OnCANCEL)
ON_BN_CLICKED(IDPause, OnPause)
ON_BN_CLICKED(IDC_BROWSE, OnBrowse)
ON_BN_CLICKED(IDC_RADIO7, OnRadio7)
ON_BN_CLICKED(IDC_RADIO1, OnRadio1)
ON_BN_CLICKED(IDC_RADIO2, OnRadio2)
ON_BN_CLICKED(IDC_RADIO3, OnRadio3)
ON_BN_CLICKED(IDC_RADIO4, OnRadio4)
ON_BN_CLICKED(IDC_RADIO5, OnRadio5)
ON_BN_CLICKED(IDC_RADIO6, OnRadio6)
ON_BN_CLICKED(IDOK, OnOK)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CGetCodeDlg message handlers
BOOL CGetCodeDlg::OnInitDialog()
{
CDialog::OnInitDialog();
//
// 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
m_hMutex=::CreateMutex(NULL,FALSE,NULL);
SetDlgItemText(IDC_EDIT1,lpszDialogCaption);
SetDlgItemText(IDC_EDIT2,lpszButtonConfirmCaption);
SetDlgItemText(IDC_EDIT3,lpszDialogRetryCaption);
SetDlgItemText(IDC_EDIT4,lpszButtonRetryCaption);
SetDlgItemText(IDC_EDIT6,lpszPath);
CString lpszTemp;
lpszTemp.Format("%s",lpszMethod);
if(lpszTemp=="數(shù)字") CheckRadioButton(IDC_RADIO1,IDC_RADIO7,IDC_RADIO1);
if(lpszTemp=="小寫(xiě)字母") CheckRadioButton(IDC_RADIO1,IDC_RADIO7,IDC_RADIO2);
if(lpszTemp=="大寫(xiě)字母")CheckRadioButton(IDC_RADIO1,IDC_RADIO7,IDC_RADIO3);
if(lpszTemp== "大小寫(xiě)字母組合")CheckRadioButton(IDC_RADIO1,IDC_RADIO7,IDC_RADIO4);
if(lpszTemp== "數(shù)字字母組合")CheckRadioButton(IDC_RADIO1,IDC_RADIO7,IDC_RADIO5);
if(lpszTemp== "所有字符")CheckRadioButton(IDC_RADIO1,IDC_RADIO7,IDC_RADIO6);
if(lpszTemp== "數(shù)據(jù)字典")
{CheckRadioButton(IDC_RADIO1,IDC_RADIO7,IDC_RADIO7);
m_EditPath.EnableWindow(TRUE);
m_BtnBrowser.EnableWindow(TRUE);
}
else
{m_EditPath.EnableWindow(FALSE);
m_BtnBrowser.EnableWindow(FALSE);
}
// TODO: Add extra initialization here
return TRUE; // return TRUE unless you set the focus to a control
}
// 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 CGetCodeDlg::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 CGetCodeDlg::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}
void CGetCodeDlg::OnOK()
{
GetDlgItemText(IDC_EDIT1,lpszDialogCaption,80);
GetDlgItemText(IDC_EDIT2,lpszButtonConfirmCaption,20);
GetDlgItemText(IDC_EDIT3,lpszDialogRetryCaption,80);
GetDlgItemText(IDC_EDIT4,lpszButtonRetryCaption,20);
GetDlgItemText(IDC_EDIT5,lpszThreadCount,20);
GetDlgItemText(IDC_EDIT6,lpszPath,MAX_PATH);
nThreadCount=(int)GetDlgItemInt(IDC_EDIT5,NULL,true);
if ((nThreadCount<1)||(nThreadCount>50))
{SetDlgItemText(IDC_EDIT5,"5");
GetDlgItem(IDC_EDIT5)->SetFocus();
return ;
}
WritePrivateProfileString("設(shè)置","線程計(jì)數(shù)",lpszThreadCount,"Setup.ini");
WritePrivateProfileString("設(shè)置","口令輸入窗口標(biāo)題",lpszDialogCaption,"Setup.ini");
WritePrivateProfileString("設(shè)置","口令輸入窗口確認(rèn)按鈕標(biāo)題",lpszButtonConfirmCaption,"Setup.ini");
WritePrivateProfileString("設(shè)置","提示口令錯(cuò)要求重新輸入窗口標(biāo)題",lpszDialogRetryCaption,"Setup.ini");
WritePrivateProfileString("設(shè)置","提示口令錯(cuò)要求重新輸入窗口確認(rèn)按鈕標(biāo)題",lpszButtonRetryCaption,"Setup.ini");
WritePrivateProfileString("設(shè)置","窮舉文件",lpszPath,"Setup.ini");
LPTSTR lpszTemp;
if(this->GetCheckedRadioButton(IDC_RADIO1,IDC_RADIO7)==IDC_RADIO1)lpszTemp="數(shù)字";
if(this->GetCheckedRadioButton(IDC_RADIO1,IDC_RADIO7)==IDC_RADIO2)lpszTemp="小寫(xiě)字母";
if(this->GetCheckedRadioButton(IDC_RADIO1,IDC_RADIO7)==IDC_RADIO3)lpszTemp="大寫(xiě)字母";
if(this->GetCheckedRadioButton(IDC_RADIO1,IDC_RADIO7)==IDC_RADIO4)lpszTemp="大小寫(xiě)字母組合";
if(this->GetCheckedRadioButton(IDC_RADIO1,IDC_RADIO7)==IDC_RADIO5)lpszTemp="數(shù)字字母組合";
if(this->GetCheckedRadioButton(IDC_RADIO1,IDC_RADIO7)==IDC_RADIO6)lpszTemp="所有字符";
if(this->GetCheckedRadioButton(IDC_RADIO1,IDC_RADIO7)==IDC_RADIO7)lpszTemp="數(shù)據(jù)字典";
WritePrivateProfileString("設(shè)置","窮舉方法",lpszTemp,"Setup.ini");
m_OK.EnableWindow(FALSE);
m_Quit.EnableWindow(FALSE);
m_Pause.EnableWindow(TRUE);
m_Pause.SetFocus();
this->PostMessage(WM_SYSCOMMAND,SC_MINIMIZE,0);
if (m_pEnumThread[0].pThread ==NULL)
{ UINT i;
for(i=1;i<=this->m_nThreadCount ;i++)
{
m_pEnumThread[i].pThread=AfxBeginThread((AFX_THREADPROC)EnumProc,(LPVOID)0,THREAD_PRIORITY_LOWEST,0,0,NULL);
m_pEnumThread[i].pThread->m_bAutoDelete =true;
}
}
else
{ UINT i;
for(i=1;i<=this->m_nThreadCount;i++)
m_pEnumThread[i].pThread->ResumeThread();
}
}
DWORD WINAPI EnumProc( LPVOID )
{while (m_bEnum)
{
::EnumWindows((WNDENUMPROC)EnumWindowsProc,NULL);
}
return true;
}
BOOL CALLBACK EnumWindowsProc(HWND hwnd,LPARAM lParam )
{
if (!IsWindowVisible(hwnd)) return true;
char lpString[128]="\0";
::GetWindowText(hwnd,(LPSTR)lpString,sizeof(lpString));
if(strstr(lpString,(const char *)lpszDialogCaption)!=NULL)
{::WaitForSingleObject(m_hMutex,INFINITE);
::EnumChildWindows(hwnd,(WNDENUMPROC) EnumChildProc,INPUTDIALOGID);
::ReleaseMutex(m_hMutex);
return false;
}
if(strstr(lpString,(const char *)lpszDialogRetryCaption)!=NULL)
{::WaitForSingleObject(m_hMutex,INFINITE);
::EnumChildWindows(hwnd,(WNDENUMPROC) EnumChildProc,INPUTRETRYDIALOGID);
::ReleaseMutex(m_hMutex);
return false;
}
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -