///process based init /// todo - destructor order(I am not sure if it is correct!!) bool PluginMng::InitPlugins(){ if (plugins_.empty()){ LoadPlugins(); uuiterator vb=plugins_.begin(),ve=plugins_.end(); for (uuiterator i=vb;i!=ve;++i){ uuplugin* p= *i; CRegKey crk; long rk=crk.Open(HKEY_LOCAL_MACHINE, _6bees_const::kplugindisabled, KEY_READ|KEY_WRITE); if (rk==ERROR_SUCCESS){ DWORD i=0; ATL::CString menuid; menuid.Format(_T("%d"),p->menuwID_); if (crk.QueryDWORDValue(menuid,i)==ERROR_SUCCESS){ p->enabled_ = false; } } if (p->enabled_){ p->init(); }else{ disabled_plugins_.push_back(p); } } fillpartswidth(); } return true; }
////////////////////////////////////////////////////////////////////////// //时间与字符串互相转换函数 ATL::CString GlobeFuns::TimeToString(const CTime &t) { ATL::CString strDateTime; strDateTime.Format("%d-%02d-%02d %02d:%02d:%02d", t.GetYear(), t.GetMonth(), t.GetDay(), t.GetHour(), t.GetMinute(), t.GetSecond()); return strDateTime; }
HRESULT TimeToString( __time64_t nTime, ATL::CString& strTime ) { ATL::CTime time(nTime); strTime.Format( TEXT("%d %d %d %d:%d:%d"), time.GetYear(), time.GetMonth(), time.GetDay(), time.GetHour(), time.GetMinute(),time.GetSecond()); return S_OK; }
PluginMng::~PluginMng(){ for (int i=0;i<(int)plugins_.size();i++){ uuplugin* uup = plugins_.at(i); CRegKey crk; long rk=crk.Open(HKEY_LOCAL_MACHINE, _6bees_const::kplugindisabled, KEY_READ|KEY_WRITE); if (rk==ERROR_SUCCESS){ ATL::CString menuid; menuid.Format(_T("%d"),uup->menuwID_); if(uup->enabled_){ crk.DeleteValue(menuid); }else{ crk.SetDWORDValue(menuid,1); } } } }
UINT WINAPI alexa::thread_getalexa(LPVOID p){ alexainfo* pas = static_cast<alexainfo*>(p); int alexarank = 0; std::wstring hostname(pas->hostname.c_str()); if(url2alexa.find(hostname)==url2alexa.end()){ alexarank = GetAlexaRank(pas->hostname.c_str()); url2alexa[hostname] = alexarank; }else{ alexarank = url2alexa[hostname]; } ATL::CString stralexa; stralexa.Format(L"%d",alexarank); pas->alexaptr->tid2panetext_[pas->tid] = stralexa; if(IsWindow(pas->psb->m_hWnd)) pas->psb->SetText(pas->paneid,stralexa); return 0; }
void CSetProxServer::ReadSettingsAndSet(int nFlag = -1) { int nType; TCHAR sUser[256] = {0}; TCHAR sPass[256] = {0}; TCHAR sHost[256] = {0}; int nPort = 80; int nValidate; ATL::CString strPort = L""; CIniFile iniFile(m_strFilePath); iniFile.GetIntValue(L"proxy", L"type", nType); if (nFlag == -1)// { if (nType == -1)//第一次使用的情况 { nType = 1; m_bChanged = TRUE; } } else { nType = nFlag; } m_ComBoHttp.SetCurSel(nType); iniFile.GetIntValue(L"proxy", L"validate", nValidate); if (nValidate == -1) { nValidate = 1;//默认情况下是需要验证的 } iniFile.GetStrValue(L"proxy", L"host", sHost, sizeof(sHost)); iniFile.GetIntValue(L"proxy", L"port", nPort); iniFile.GetStrValue(L"proxy", L"user", sUser, sizeof(sUser)); iniFile.GetStrValue(L"proxy", L"password", sPass, sizeof(sPass)); HWND hWndVerify = ::GetDlgItem(GetViewHWND(), IDC_COMBO_PROX_SERVER_VERIFY); HWND hWndAddr = ::GetDlgItem(GetViewHWND(), IDC_EDITBOX_PROX_SERVER_ADDR); HWND hWndPort = ::GetDlgItem(GetViewHWND(), IDC_EDITBOX_PROX_SERVER_PORT); HWND hWndAccount = ::GetDlgItem(GetViewHWND(), IDC_EDITBOX_PROX_SERVER_ACCOUNT); HWND hWndPass = ::GetDlgItem(GetViewHWND(), IDC_EDITBOX_PROX_SERVER_PASS); if (nType == 0)//不使用的情况 { ::EnableWindow(hWndVerify, FALSE); ::EnableWindow(hWndAddr, FALSE); ::EnableWindow(hWndPort, FALSE); ::EnableWindow(hWndAccount, FALSE); ::EnableWindow(hWndPass, FALSE); ReSet(); } else { if (nPort == -1) { if (nType == 1) nPort = 80; else if (nType == 2) nPort = 1080; } strPort.Format(L"%d", nPort); ::EnableWindow(hWndVerify, TRUE); ::EnableWindow(hWndAddr, TRUE); ::EnableWindow(hWndPort, TRUE); ::EnableWindow(hWndAccount, nValidate); ::EnableWindow(hWndPass, nValidate); if (nValidate <= 0)//不需要验证的时候 { memset(sUser, 0, sizeof(sUser)); memset(sPass, 0, sizeof(sUser)); } m_ComBoVerify.SetCurSel(nValidate); m_wndEditAddr.SetWindowText(sHost); m_wndEditPort.SetWindowText(strPort); m_wndEditAccount.SetWindowText(sUser); m_wndEditPass.SetWindowText(sPass); } return; }