CStrVector CFilesHashDlg::ParseCmdLine() { // 从命令行获取文件路径 CStrVector Parameters; #if defined(UNICODE) || defined(_UNICODE) size_t cmdLen = wcslen(theApp.m_lpCmdLine); #else size_t cmdLen = strlen(theApp.m_lpCmdLine); #endif if(cmdLen > 0) { for(size_t i = 0; i < cmdLen; ++i) { CString Parameter(""); if(theApp.m_lpCmdLine[i] == '"') { ++i; for(; theApp.m_lpCmdLine[i] != '"'; ++i) Parameter.AppendChar(theApp.m_lpCmdLine[i]); Parameters.push_back(Parameter); ++i; } else { for(; theApp.m_lpCmdLine[i] != ' '; ++i) Parameter.AppendChar(theApp.m_lpCmdLine[i]); Parameters.push_back(Parameter); } } } // 从命令行获取文件路径结束 return Parameters; }
CStrVector CH3CDlg::ParseCmdLine() { // 从命令行获取文件路径 CStrVector parameters; tstring tstrCmdLine(theApp.m_lpCmdLine); size_t cmdLen = tstrCmdLine.length(); if(cmdLen > 0) { for(size_t i = 0; i < cmdLen; ++i) { CString para(_T("")); if(tstrCmdLine[i] == _T('"')) { ++i; for(; i < cmdLen && tstrCmdLine[i] != _T('"'); ++i) para.AppendChar(tstrCmdLine[i]); parameters.push_back(para); ++i; } else { for(; i < cmdLen && tstrCmdLine[i] != _T(' '); ++i) para.AppendChar(tstrCmdLine[i]); parameters.push_back(para); } } } // 从命令行获取文件路径结束 return parameters; }
BOOL CFilesHashDlg::OnInitDialog() { CDialog::OnInitDialog(); // 设置此对话框的图标。当应用程序主窗口不是对话框时,框架将自动 // 执行此操作 SetIcon(m_hIcon, TRUE); // 设置大图标 SetIcon(m_hIcon, FALSE); // 设置小图标 // TODO:在此添加额外的初始化代码 InitializeCriticalSection(&g_criticalSection); m_bruEditBkg.CreateSolidBrush(RGB(255, 255, 255)); PrepareAdvTaskbar(); m_bFind = FALSE; m_btnClr.SetWindowText(MAINDLG_CLEAR); m_hWorkThread = NULL; m_waitingExit = FALSE; m_calculateTime = 0.0; m_timer = -1; m_prog.SetStep(1); m_bLimited = IsLimitedProc(); CWnd* pWnd; pWnd = GetDlgItem(IDC_STATIC_SPEED); pWnd->SetWindowText(_T("")); pWnd = GetDlgItem(IDC_STATIC_TIME); pWnd->SetWindowText(_T("")); pWnd = GetDlgItem(IDC_STATIC_FILE); pWnd->SetWindowText(MAINDLG_FILE_PROGRESS); pWnd = GetDlgItem(IDC_STATIC_WHOLE); pWnd->SetWindowText(MAINDLG_TOTAL_PROGRESS); pWnd = GetDlgItem(IDC_STATIC_UPPER); pWnd->SetWindowText(MAINDLG_UPPER_HASH); pWnd = GetDlgItem(IDC_STATIC_UPPER); pWnd->SetWindowText(MAINDLG_UPPER_HASH); pWnd = GetDlgItem(IDC_STATIC_TIMETITLE); pWnd->SetWindowText(MAINDLG_TIME_TITLE); m_btnOpen.SetWindowText(MAINDLG_OPEN); m_btnStop.SetWindowText(MAINDLG_STOP); m_btnCopy.SetWindowText(MAINDLG_COPY); m_btnFind.SetWindowText(MAINDLG_VERIFY); m_btnExit.SetWindowText(MAINDLG_EXIT); pWnd = GetDlgItem(IDC_ABOUT); pWnd->SetWindowText(MAINDLG_ABOUT); EnterCriticalSection(&g_criticalSection); { m_thrdData.hWnd = m_hWnd; m_thrdData.uppercase = FALSE; m_thrdData.nFiles = 0; m_thrdData.strAll = _T(""); m_thrdData.resultList.clear(); } LeaveCriticalSection(&g_criticalSection); pTl = NULL; m_editMain.SetLimitText(UINT_MAX); m_editMain.SetWindowText(MAINDLG_INITINFO); if(ContextMenuExisted()) { // 已经添加右键菜单 m_btnContext.SetWindowText(MAINDLG_REMOVE_CONTEXT_MENU); } else { m_btnContext.SetWindowText(MAINDLG_ADD_CONTEXT_MENU); } pWnd = (CStatic*)GetDlgItem(IDC_STATIC_ADDRESULT); pWnd->SetWindowText(_T("")); SetCtrls(FALSE); // 从命令行获取文件路径 CStrVector Paras = ParseCmdLine(); ClearFilePaths(); for(CStrVector::iterator ite = Paras.begin(); ite != Paras.end(); ++ite) { m_thrdData.fullPaths.push_back(*ite); ++m_thrdData.nFiles; } // 从命令行获取文件路径结束 m_thrdData.threadWorking = FALSE; m_prog.SetRange(0, 99); m_progWhole.SetRange(0, 99); m_chkUppercase.SetCheck(0); if(m_thrdData.nFiles > 0) SetTimer(4, 50, NULL); // 使 DoMD5() 在 OnInitDialog() 之后执行 return TRUE; // 除非设置了控件的焦点,否则返回 TRUE }
BOOL CH3CDlg::OnInitDialog() { CDialog::OnInitDialog(); // 设置此对话框的图标。当应用程序主窗口不是对话框时,框架将自动 // 执行此操作 SetIcon(m_hIcon, TRUE); // 设置大图标 SetIcon(m_hIcon, FALSE); // 设置小图标 // TODO: 在此添加额外的初始化代码 CreateMutex(NULL, true, _T("Huawei")); if(GetLastError() == ERROR_ALREADY_EXISTS) { MessageBoxEx(NULL, _T("已经有一个实例在运行!"), _T("H3C 802.1x"), MB_OK|MB_APPLMODAL|MB_ICONEXCLAMATION, 0x0804); Shell_NotifyIcon(NIM_DELETE,&tnd); PostQuitMessage(0); return FALSE; } // 读取信息 GetConfig(); PIP_ADAPTER_INFO pAdapter = NULL; DWORD dwRetVal = 0; pAdapterInfo = (IP_ADAPTER_INFO *) malloc( sizeof(IP_ADAPTER_INFO) ); ULONG ulOutBufLen = sizeof(IP_ADAPTER_INFO); // Make an initial call to GetAdaptersInfo to get // the necessary size into the ulOutBufLen variable if (GetAdaptersInfo( pAdapterInfo, &ulOutBufLen) == ERROR_BUFFER_OVERFLOW) { free(pAdapterInfo); pAdapterInfo = (IP_ADAPTER_INFO *)malloc(ulOutBufLen); } int devCount = 0; if ((dwRetVal = GetAdaptersInfo( pAdapterInfo, &ulOutBufLen)) == NO_ERROR) { pAdapter = pAdapterInfo; while (pAdapter) { string strDescri(pAdapter->Description); m_device.AddString(strtotstr(strDescri).c_str()); string strMac = GetMac(pAdapter); if(m_deviceUsed == strMac) m_deviceNum = devCount; pAdapter = pAdapter->Next; ++devCount; } } //else //{ // printf("Call to GetAdaptersInfo failed.\n"); //} if(m_deviceNum >= devCount) m_deviceNum = 0; GetMac(m_deviceNum); UpdateData(FALSE); CStrVector Paras = ParseCmdLine(); for(CStrVector::iterator ite = Paras.begin(); ite != Paras.end(); ++ite) if(!(*ite).Compare(_T("-mini"))) SetTimer(1, 200, NULL); SetCtrls(FALSE); return TRUE; // 除非将焦点设置到控件,否则返回 TRUE }