BOOL Split( LPCTSTR lpString, CSimpleArray<CString>& arr, TCHAR delimiter ) { if(lpString==NULL || _tcslen(lpString)==0) return FALSE; arr.RemoveAll(); CString szString = lpString; int nStart = 0; int nOffset; while(1) { nOffset = szString.Find(delimiter, nStart); if(nOffset > 0) { arr.Add(szString.Mid(nStart, nOffset-nStart)); } else if(nOffset==-1) { arr.Add(szString.Mid(nStart)); break; } nStart = nOffset + 1; }; return TRUE; }
int CSpecialApp::SplitCString1(CString strIn, CSimpleArray<CString>& vec_String, TCHAR division) { vec_String.RemoveAll(); if (!strIn.IsEmpty()) { int nCount = 0; int nPos = -1; nPos = strIn.Find(division); CString strTemp = strIn; while (nPos != -1) { CString strSubString = strTemp.Left(nPos); strTemp = strTemp.Right(strTemp.GetLength() - nPos-1); nPos = strTemp.Find(division); nCount++; vec_String.Add(strSubString); } if (nCount == vec_String.GetSize()) { CString str; int nSize = strIn.ReverseFind(division); str = strIn.Right(strIn.GetLength()-nSize-1); vec_String.Add(str); } } return vec_String.GetSize(); }
STDMETHODIMP CLDAPQuery::pageQuery( /* [in] */ LONG connect_id, /* [in] */ BSTR basedn, /* [in] */ BSTR scope, /* [in] */ BSTR filter, /* [in] */ BSTR attributes, /* [in] */ ULONG total_results, /* [retval][out] */ LONG* results_id) { m_errorCode = 0L; const int id = m_connections.FindKey(connect_id); if(id > -1) { ÑConnectInfo * const cinfo = m_connections.GetValueAt(id); const PLDAP ld = cinfo->ld(); const ULONG no_limit = LDAP_NO_LIMIT; ULONG ulScope = LDAP_SCOPE_BASE; CString csScope = scope; csScope.MakeLower(); if(csScope == _T("subtree")) ulScope = LDAP_SCOPE_SUBTREE; else if(csScope == _T("onelevel")) ulScope = LDAP_SCOPE_ONELEVEL; else if(csScope == _T("base")) ulScope = LDAP_SCOPE_BASE; CString csBaseDN = basedn; if(csBaseDN.IsEmpty() && (ulScope == LDAP_SCOPE_ONELEVEL || (!cinfo->canFindFromRoot() && ulScope == LDAP_SCOPE_SUBTREE))) { csBaseDN = cinfo->defaultNamingContext(); } CSimpleArray<PTCHAR> attributesArr; PTCHAR nextAttributes = NULL; CString csArrs = attributes; PTCHAR attribute = _tcstok_s(csArrs.GetBuffer(), _T(","), &nextAttributes); while(attribute != NULL) { attributesArr.Add(attribute); attribute = _tcstok_s(NULL, _T(","), &nextAttributes); } csArrs.ReleaseBuffer(); attributesArr.Add(NULL); // NULL-terminated array PLDAPSearch pPages = ldap_search_init_page(ld, csBaseDN.GetBuffer(), ulScope, CString(filter).GetBuffer(), attributesArr.GetData(), 0, NULL, NULL, no_limit, total_results, NULL); m_errorCode = LdapGetLastError(); if(pPages) { *results_id = cinfo->addResult(pPages); } } return S_OK; }
//------------------------------------------------------------------------ //! Converts a color setting value into a delimited string //! //! @param color The setting value //! @return The delimited string //------------------------------------------------------------------------ CString CViewConfigSection::ConvertColorSetting(COLORREF color) const { CSimpleArray<CString> strArray; CString strValue; strValue.Format(_T("%u"), GetRValue(color)); strArray.Add(strValue); strValue.Format(_T("%u"), GetGValue(color)); strArray.Add(strValue); strValue.Format(_T("%u"), GetBValue(color)); strArray.Add(strValue); return ConvertArraySetting(strArray); }
//------------------------------------------------------------------------ //! Converts a rectangle setting value into a delimited string //! //! @param rect The setting value //! @return The delimited string //------------------------------------------------------------------------ CString CViewConfigSection::ConvertRectSetting(const RECT& rect) const { CSimpleArray<CString> strArray; CString strValue; strValue.Format(_T("%d"), rect.left); strArray.Add(strValue); strValue.Format(_T("%d"), rect.top); strArray.Add(strValue); strValue.Format(_T("%d"), rect.right); strArray.Add(strValue); strValue.Format(_T("%d"), rect.bottom); strArray.Add(strValue); return ConvertArraySetting(strArray); }
void CBkIgnoreDlg::NeedUpdateSoft(CSoftListItemData* datalist) { if (datalist->m_bIgnore) datalist->m_bIgnore = FALSE; CSimpleArray<CSoftListItemData*> arrData; for (int i = 0; i < m_arrData.GetSize(); i++) { CSoftListItemData *pData = m_arrData[i]; if (pData && pData->m_bIgnore) arrData.Add(pData); } m_arrData.RemoveAll(); for (int i = 0; i < arrData.GetSize(); i++) { CSoftListItemData *pData = arrData[i]; if (pData && pData->m_bIgnore) m_arrData.Add(pData); } int nIgnoreCount = m_arrData.GetSize(); this->FormatRichText( IDC_CTL_UPDATE_IGNORE_TITLE, BkString::Get(IDS_DLG_UPDATE_IGNORE_COUNT_FORMAT), nIgnoreCount ); m_necessList->SetItemCount(nIgnoreCount); if (nIgnoreCount == 0) { this->SetItemVisible(IDC_CTL_UPDATE_IGNORE_WND,FALSE); this->SetItemVisible(IDC_CTL_UPDATE_IGNORE_NONE,TRUE); this->EnableItem( IDC_UPDATE_CHECK_IGNORE_ALL, FALSE); this->EnableItem( IDC_CTL_UPDATE_IGNORE_SEL, FALSE); } }
bool MtlGetDropFileName(IDataObject *pDataObject, CSimpleArray<CString> &arrFileNames) { if ( !MTL::MtlIsDataAvailable(pDataObject, CF_HDROP) ) return false; FORMATETC formatetc = { CF_HDROP, NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL }; STGMEDIUM stgmedium; HRESULT hr = pDataObject->GetData(&formatetc, &stgmedium); if (FAILED(hr) || stgmedium.hGlobal == NULL) { return false; } HDROP hDropInfo = (HDROP) stgmedium.hGlobal; UINT nFiles = ::DragQueryFile(hDropInfo, (UINT) -1, NULL, 0); for (UINT iFile = 0; iFile < nFiles; iFile++) { TCHAR szFileName[_MAX_PATH]; szFileName[0] = 0; ::DragQueryFile(hDropInfo, iFile, szFileName, _MAX_PATH); arrFileNames.Add( CString(szFileName) ); } ::DragFinish(hDropInfo); // required? ::ReleaseStgMedium(&stgmedium); if (arrFileNames.GetSize() > 0) return true; else return false; }
/* =================================================== * CRegEntry::SetMulti(LPCTSTR lpszValue, size_t nLen, bool bInternal) * * Stores an array of null-terminated string, terminated by two null characters. * For Example: First String\0Second\Third\0\0 * * Important Params: * * LPCTSTR lpszValue: The string consisting of the null-terminated string array * size_t nLen: The number of characters in the string, including null characters * * Note: For inserting individual null-terminated strings into the array, * use MultiAdd or MultiSetAt. */ BOOL ReadRegMString( HKEY hkey, LPCTSTR pszSubKey, LPCTSTR pszValue, CSimpleArray<CString> &ms ) { DWORD dwBuffer = _MAX_REG_VALUE; DWORD dwType = REG_MULTI_SZ; TCHAR *pbuf = new TCHAR[_MAX_REG_VALUE]; if( pbuf && ERROR_SUCCESS==SHGetValue(hkey, pszSubKey, pszValue, &dwType, pbuf, &dwBuffer) ) { size_t nCur = 0, nPrev = 0, nShortLen = dwBuffer/sizeof(TCHAR); if( nShortLen>2 ) { if (*(pbuf + nShortLen-1) == '\0') nShortLen--; while( (nCur = (int)(_tcschr(pbuf+nPrev, '\0')-pbuf)) < nShortLen ) { ms.Add( pbuf+nPrev ); nPrev = nCur+1; } } return TRUE; } return FALSE; }
void CEventManager::FireEvent(EventQueueItem_t *pEI) { CListener *pListener; if (pEI->Flags & ET_BROADCAST) { int i; CSimpleArray<CListener *> FireOrder; // firing an event can cause a listener to be removed from the list // so we make a copy of the list, and then fire each one. for (i = 0 ; i < m_ListenerList.GetSize() ; i++) FireOrder.Add(m_ListenerList[i]); for (i = 0 ; i < FireOrder.GetSize() ; i++) { pListener = FireOrder[i]; // only fire the event if it's still in the list! (if it's not then pListener is invalid..) if (m_ListenerList.Find(pListener) >= 0) pListener->OnEvent(pEI->EventID,pEI->pData); } } else { pEI->pFrom->OnEvent(pEI->EventID,pEI->pData); } }
int CLDEditTxtFile::_LoadTxtFileWithItems(CSimpleArray<CString>& arrFileItems) { int nRet = -1; USES_CONVERSION; char pszFilePath[MAX_PATH] = {0}; StringCbPrintfA(pszFilePath, sizeof(pszFilePath), "%s", W2A(m_strTxtFile)); FILE* pFile = NULL; //open file fopen_s(&pFile, const_cast<char*>(pszFilePath), "r"); if (NULL == pFile) return nRet; char pszFileValue[1024] = {0}; ZeroMemory(pszFileValue, sizeof(pszFileValue)); arrFileItems.RemoveAll(); while(NULL != fgets(pszFileValue, sizeof(pszFileValue), pFile)) { if (NULL != m_pStop && TRUE == *m_pStop) return nRet; arrFileItems.Add(CString(pszFileValue)); ZeroMemory(pszFileValue, sizeof(pszFileValue)); } if (NULL != pFile) fclose(pFile); pFile = NULL; nRet = arrFileItems.GetSize(); return nRet; }
BOOL CEnumerateSerial::UsingGetDefaultCommConfig(CSimpleArray<UINT>& ports) #endif { //Make sure we clear out any elements which may already be in the array #if defined CENUMERATESERIAL_USE_STL ports.clear(); #else ports.RemoveAll(); #endif //Up to 255 COM ports are supported so we iterate through all of them seeing //if we can get the default configuration for (UINT i=1; i<256; i++) { //Form the Raw device name CString sPort; sPort.Format(_T("COM%u"), i); COMMCONFIG cc; DWORD dwSize = sizeof(COMMCONFIG); if (GetDefaultCommConfig(sPort, &cc, &dwSize)) { #if defined CENUMERATESERIAL_USE_STL ports.push_back(i); #else ports.Add(i); #endif } } //Return the success indicator return TRUE; }
N2FCORE_API bool ControllerWebServices::InitializeController(TWSCutsomEPList& list) { LOGMSG("Initializing"); bool result = false; CSimpleArray<WebServiceBase*> arrayServices; arrayServices.Add(new WebServiceN2FMemberService); arrayServices.Add(new WebServiceN2FMemberService_v2); arrayServices.Add(new WebServiceN2FPhotoOrganise); arrayServices.Add(new WebServiceN2FPhotoOrganise_v2); arrayServices.Add(new WebServiceN2FMemberService_v3); arrayServices.Add(new WebServiceN2FSnapUpService); // add all supported web-services here for ( int i = 0; i < arrayServices.GetSize(); ++i ) { iSupportedServices.Add(arrayServices[i]->GetType(), arrayServices[i]); } // custom end-points initialization for ( int i = 0; i < list.GetSize(); ++i ) { int idxFound = iSupportedServices.FindKey(list[i].wsType); if ( -1 != idxFound ) { iSupportedServices.GetValueAt(idxFound)->Initialize(list[i].wsEndPoint); } } CString csEmpty; for ( int i = 0; i < iSupportedServices.GetSize(); ++i ) { WebServiceBase *wsb = iSupportedServices.GetValueAt(i); if ( false == wsb->IsInitialized() ) wsb->Initialize(csEmpty); } result = true; return result; LOGMSG("Initialized"); }
BOOL CKSogoClean::ScanSogoAdvForm() { if (!_CheckSogouExist()) { g_vsNoinstallapp.Add(SOGO_ADVFORM); return TRUE; } BOOL bRet = FALSE; WCHAR szSogoAppPath[MAX_PATH] = {0}; std::wstring strTemp; SHGetSpecialFolderPath(NULL, szSogoAppPath, CSIDL_APPDATA, FALSE); PathAppend(szSogoAppPath, L"SogouExplorer"); strTemp = szSogoAppPath; PathAppend(szSogoAppPath, L"FormData.dat"); g_fnScanFile(g_pMain,BEGINPROC(SOGO_ADVFORM),0,0,0); std::wstring str; std::vector<std::wstring>::iterator it; for (it = g_listProcessName.begin(); it != g_listProcessName.end(); it++ ) { str = *it; transform(str.begin(), str.end(), str.begin(), towlower); if (str == L"sogouexplorer.exe") { str = L"正在运行,跳过"; goto clean0; } } str = L""; if (m_bScan) { ScanDbTable(szSogoAppPath, L"IndexPrecise", SOGO_ADVFORM); ScanDbTable(szSogoAppPath, L"PreciseData", SOGO_ADVFORM); std::vector<std::wstring> vec_userInfo; std::vector<std::wstring>::iterator it; if (GetUserInfo(vec_userInfo)) { for (it = vec_userInfo.begin(); it != vec_userInfo.end(); it++) { std::wstring strUserPath; strUserPath = strTemp; strUserPath += L"\\"; strUserPath += *it; strUserPath += L"\\FormData.dat"; ScanDbTable(strUserPath, L"IndexPrecise", SOGO_ADVFORM); ScanDbTable(strUserPath, L"PreciseData", SOGO_ADVFORM); } } } clean0: g_fnScanFile(g_pMain,ENDPROC(SOGO_ADVFORM),str.c_str(),0,0); return bRet; }
//------------------------------------------------------------------------ //! Retrieves a integer-array setting value for the view //! //! @param strName Name of setting //! @param values integer-array //! @param strDelimiter The delimiter for splitting a single string into an array //------------------------------------------------------------------------ void CViewConfigSection::GetArraySetting(const CString& strName, CSimpleArray<int>& values, const CString& strDelimiter) const { CSimpleArray<CString> strArray; GetArraySetting(strName, strArray, strDelimiter); for (int i = 0; i < strArray.GetSize(); ++i) { int value = _ttoi(strArray[i]); values.Add(value); } }
int CLDEditTxtFile::_fgets(CSimpleArray<CString>& arrFileItems) { int nRet = -1; USES_CONVERSION; arrFileItems.RemoveAll(); HANDLE hFile = INVALID_HANDLE_VALUE; hFile = CreateFile(m_strTxtFile, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); if (INVALID_HANDLE_VALUE == hFile) return nRet; char *pszFileBuffer = NULL; do { DWORD dwFileSize = 0; dwFileSize = ::GetFileSize(hFile, NULL); if (0 == dwFileSize || dwFileSize > 1*1024*1024)//大于1M的文件默认任务失败 break; dwFileSize += 1; pszFileBuffer = new char[dwFileSize]; ZeroMemory(pszFileBuffer, dwFileSize); DWORD dwRetSize = 0; if (FALSE == ReadFile(hFile, pszFileBuffer, dwFileSize, &dwRetSize, NULL) || 0 == dwRetSize) break; int nFind = -1; CString strValue;//(CA2W(pszFileBuffer)); strValue = CA2W(pszFileBuffer); if (FALSE == strValue.IsEmpty()) strValue += TEXT("\r\n"); nFind = strValue.Find('\n'); while(nFind >= 0) { if (NULL != m_pStop && TRUE == *m_pStop) break; CString strTmp; strTmp = strValue.Left(nFind+1); arrFileItems.Add(strTmp); strValue = strValue.Mid(nFind+1); nFind = -1; nFind = strValue.Find('\n'); } nRet = 0; } while (FALSE); if (INVALID_HANDLE_VALUE != hFile) CloseHandle(hFile); hFile = NULL; SAFE_DELETE_ARRAY_PTR(pszFileBuffer); return nRet; }
BOOL CEnumerateSerial::UsingEnumPorts(CSimpleArray<UINT>& ports) #endif { //Make sure we clear out any elements which may already be in the array #if defined CENUMERATESERIAL_USE_STL ports.clear(); #else ports.RemoveAll(); #endif //Call the first time to determine the size of the buffer to allocate DWORD cbNeeded = 0; DWORD dwPorts = 0; EnumPorts(NULL, 1, NULL, 0, &cbNeeded, &dwPorts); //What will be the return value BOOL bSuccess = FALSE; //Allocate the buffer and recall CAutoHeapAlloc portsBuffer; if (portsBuffer.Allocate(cbNeeded)) { BYTE* pPorts = static_cast<BYTE*>(portsBuffer.m_pData); bSuccess = EnumPorts(NULL, 1, pPorts, cbNeeded, &cbNeeded, &dwPorts); if (bSuccess) { PORT_INFO_1* pPortInfo = reinterpret_cast<PORT_INFO_1*>(pPorts); for (DWORD i=0; i<dwPorts; i++) { //If it looks like "COMX" then //add it to the array which will be returned size_t nLen = _tcslen(pPortInfo->pName); if (nLen > 3) { if ((_tcsnicmp(pPortInfo->pName, _T("COM"), 3) == 0) && IsNumeric(&(pPortInfo->pName[3]), TRUE)) { //Work out the port number int nPort = _ttoi(&(pPortInfo->pName[3])); #if defined CENUMERATESERIAL_USE_STL ports.push_back(nPort); #else ports.Add(nPort); #endif } } pPortInfo++; } } } else SetLastError(ERROR_OUTOFMEMORY); return bSuccess; }
BOOL CKSogoClean::ScanSogoHistory() { if (!_CheckSogouExist()) { g_vsNoinstallapp.Add(BROWSERSCLEAN_SOGO); return TRUE; } BOOL bRet = FALSE; WCHAR strPath[MAX_PATH] = {0}; std::wstring strDbPath; std::wstring strDbTemp; std::wstring str; str = L""; SHGetSpecialFolderPath(NULL, strPath, CSIDL_APPDATA, FALSE); g_fnScanFile(g_pMain, BEGINPROC(BROWSERSCLEAN_SOGO), 0, 0, 0); std::vector<std::wstring>::iterator it; for (it = g_listProcessName.begin(); it != g_listProcessName.end(); it++ ) { str = *it; transform(str.begin(), str.end(), str.begin(), towlower); if (str == L"sogouexplorer.exe") { str = L"正在运行,跳过"; goto clean0; } } str = L""; if (m_bScan) { PathAppend(strPath, L"SogouExplorer"); strDbTemp = strPath; strDbPath = strPath; strDbPath += L"\\uhistory.db"; ScanDbTable(strDbPath, L"tb_urlhistory", BROWSERSCLEAN_SOGO); ScanDbTable(strDbPath, L"tb_urlinfo", BROWSERSCLEAN_SOGO); strDbPath = strDbTemp; strDbPath += L"\\HistoryUrl.db"; ScanDbTable(strDbPath, L"UserRankUrl", BROWSERSCLEAN_SOGO); ScanDbTable(strDbPath, L"often", BROWSERSCLEAN_SOGO); ScanDbTable(strDbPath, L"UndoUrl", BROWSERSCLEAN_SOGO); EnumUserInfo(BROWSERSCLEAN_SOGO); strDbPath = strDbTemp; strDbPath += L"\\Webkit\\Cache"; CSimpleArray<CString> vec_file; m_appHistory.CommfunFile(BROWSERSCLEAN_SOGO, strDbPath.c_str(), vec_file); } clean0: g_fnScanFile(g_pMain, ENDPROC(BROWSERSCLEAN_SOGO), str.c_str(), 0, 0); return bRet; }
BOOL CRegOpt::DoEnumCurrnetSubKey(HKEY hRootKey,LPCTSTR lpcKey,CSimpleArray<CString>& vec_Key) { HKEY hKey; LONG lResult; //打开键 lResult = RegOpenKeyEx(hRootKey, lpcKey, NULL, KEY_READ, &hKey ); if(lResult != ERROR_SUCCESS) { m_iErrCode = lResult; return FALSE; } //枚举键名 BOOL bRet = TRUE; DWORD dwIndex=0; do { TCHAR szKey[MAX_PATH]={0}; DWORD dwKey = sizeof(szKey); lResult =RegEnumKey(hKey,dwIndex,szKey,dwKey); dwIndex++; if (lResult != ERROR_SUCCESS) { if (lResult == ERROR_NO_MORE_ITEMS) { bRet = TRUE; break; } else { bRet = FALSE; m_iErrCode = lResult; break; } } vec_Key.Add(szKey); } while (1); RegCloseKey(hKey); return bRet; }
//------------------------------------------------------------------------ //! Adds a profile to the official list of column configuration profiles //! //! @param strProfile Name of the profile //------------------------------------------------------------------------ void CViewConfigSectionProfiles::AddProfile(const CString& strProfile) { // Add the strProfile to the list if not already there CSimpleArray<CString> profiles; GetProfiles(profiles); for (int i = 0; i < profiles.GetSize(); ++i) if (profiles[i] == strProfile) return; CString noconst(strProfile); profiles.Add(noconst); WriteSetting(m_ViewName, _T("CurrentProfiles"), ConvertArraySetting(profiles, _T(", "))); }
//------------------------------------------------------------------------ //! Splits a delimited string into a string-array //! //! @param strArray The delimited string //! @param values The string array //! @param strDelimiter The delimiter //------------------------------------------------------------------------ void CViewConfigSection::SplitArraySetting(const CString& strArray, CSimpleArray<CString>& values, const CString& strDelimiter) const { // Perform tokenize using strDelimiter int cur_pos = 0; int prev_pos = 0; int length = strArray.GetLength(); while (cur_pos < length) { cur_pos = strArray.Find(strDelimiter, prev_pos); if (cur_pos == -1) { CString value = strArray.Mid(prev_pos, length - prev_pos); values.Add(value); break; } else { CString value = strArray.Mid(prev_pos, cur_pos - prev_pos); values.Add(value); prev_pos = cur_pos + strDelimiter.GetLength(); } } }
bool GetListCheckedItems(CListViewCtrlEx &listCtrl, CSimpleArray<int> &arr, BOOL *pIsRadio) { if(pIsRadio) *pIsRadio = FALSE; for(int i=0; i<listCtrl.GetItemCount(); ++i) { if( listCtrl.GetCheckState(i, pIsRadio) ) { T_VulListItemData *pItem = (T_VulListItemData*) listCtrl.GetItemData( i ); if(pItem) arr.Add( pItem->nID ); } } return arr.GetSize()>0; }
BOOL CEnumerateSerial::UsingCreateFile(CSimpleArray<UINT>& ports) #endif { //Make sure we clear out any elements which may already be in the array #if defined CENUMERATESERIAL_USE_STL ports.clear(); #else ports.RemoveAll(); #endif //Up to 255 COM ports are supported so we iterate through all of them seeing //if we can open them or if we fail to open them, get an access denied or general error error. //Both of these cases indicate that there is a COM port at that number. for (UINT i=1; i<256; i++) { //Form the Raw device name CString sPort; sPort.Format(_T("\\\\.\\COM%u"), i); //Try to open the port BOOL bSuccess = FALSE; CAutoHandle port(CreateFile(sPort, GENERIC_READ | GENERIC_WRITE, 0, 0, OPEN_EXISTING, 0, 0)); if (port == INVALID_HANDLE_VALUE) { DWORD dwError = GetLastError(); //Check to see if the error was because some other app had the port open or a general failure if (dwError == ERROR_ACCESS_DENIED || dwError == ERROR_GEN_FAILURE || dwError == ERROR_SHARING_VIOLATION || dwError == ERROR_SEM_TIMEOUT) bSuccess = TRUE; } else { //The port was opened successfully bSuccess = TRUE; } //Add the port number to the array which will be returned if (bSuccess) { #if defined CENUMERATESERIAL_USE_STL ports.push_back(i); #else ports.Add(i); #endif } } //Return the success indicator return TRUE; }
void CPluginPropertyPage::_GetData() { CSimpleMap<int , CSimpleArray<CString>*> map; for (int nType = PLT_TOOLBAR/*1*/; nType <= PLUGIN_TYPECNT; nType++) { CSimpleArray<CString>*pAry = new CSimpleArray<CString>; map.Add( nType, pAry ); } int nIndex; for (nIndex = 0; nIndex < m_listview.GetItemCount(); nIndex++) { CString strFile; m_listview.GetItemText( nIndex, 0, strFile ); if ( FALSE == m_listview.GetCheckState( nIndex ) ) continue; int nType = int( m_listview.GetItemData( nIndex ) ); CSimpleArray<CString>* pAry = NULL; pAry = map.Lookup( nType ); if (NULL == pAry) continue; pAry->Add( strFile ); } for (nIndex = 0; nIndex < map.GetSize(); nIndex++) { CSimpleArray<CString>*pAry = NULL; pAry = map.GetValueAt( nIndex ); int nType = map.GetKeyAt( nIndex ); CString strKey; strKey.Format( _T("Plugin%02d"), nType ); CIniFileO pr( g_szIniFileName, strKey ); pr.SetValue( pAry->GetSize(), _T("Count") ); for (int nNo = 0; nNo < pAry->GetSize(); nNo++) { strKey.Format(_T("%02d"), nNo); pr.SetString( (*pAry)[nNo], strKey ); } delete pAry; } }
int FillDownloadsItem(const CSimpleArray<T> &arr, const IntArray&arrayId, CSimpleArray<T_RepairItem>&arrDownloadItem) { int count = 0; for(int i=0; i<arrayId.GetSize(); ++i) { int nID = arrayId[i]; T pItem = FindArrayItem(arr, nID); if(pItem) { arrDownloadItem.Add( T_RepairItem(pItem) ); ++ count; } } return count; }
bool GetListCheckedItems(CListViewCtrlEx &listCtrl, CSimpleArray<int> &arr) { for(int i=0; i<listCtrl.GetItemCount(); ++i) { if( listCtrl.GetCheckState(i) ) { T_VulListItemData *pItem = (T_VulListItemData*) listCtrl.GetItemData( i ); if(pItem) arr.Add( pItem->nID ); } } if(arr.GetSize()==0) { ::MessageBox(NULL, _T("没有选择内容"), NULL, MB_OK); } return arr.GetSize()>0; }
BOOL CKSogoClean::ScanSogoCookies() { if (!_CheckSogouExist()) { g_vsNoinstallapp.Add(SOGO_COOKIES); return TRUE; } BOOL bRet = FALSE; WCHAR szCookiesPath[MAX_PATH] = {0}; WCHAR szSogoAppPath[MAX_PATH] = {0}; std::wstring strFilePath; CSimpleArray<CString> vec_file; SHGetSpecialFolderPath(NULL, szCookiesPath, CSIDL_COOKIES, FALSE); SHGetSpecialFolderPath(NULL, szSogoAppPath, CSIDL_APPDATA, FALSE); PathAppend(szSogoAppPath, L"SogouExplorer\\Webkit\\Cookies"); strFilePath = szSogoAppPath; g_fnScanFile(g_pMain, BEGINPROC(SOGO_COOKIES), 0, 0, 0); std::wstring str; std::vector<std::wstring>::iterator it; for (it = g_listProcessName.begin(); it != g_listProcessName.end(); it++ ) { str = *it; transform(str.begin(), str.end(), str.begin(), towlower); if (str == L"sogouexplorer.exe") { str = L"正在运行,跳过"; goto clean0; } } str = L""; if (m_bScan) { m_appHistory.CommfunFile(SOGO_COOKIES, szCookiesPath, vec_file); ScanDbTable(strFilePath, L"cookies", SOGO_COOKIES); } clean0: g_fnScanFile(g_pMain, ENDPROC(SOGO_COOKIES), str.c_str(), 0, 0); return bRet; }
static EnvDTE::ProjectItemPtr EnumItem(EnvDTE::ProjectPtr & pProject, CSimpleArray<CString> & ar, EnvDTE::ProjectItemPtr pPrevElem) { EnvDTE::ProjectItemsPtr pItems = NULL; if (pPrevElem == NULL) { pProject->get_ProjectItems(&pItems); } else { pPrevElem->get_ProjectItems(&pItems); } if (pItems == NULL) return EnvDTE::ProjectItemPtr(NULL); long Count; pItems->get_Count(&Count); if (Count == 0) return EnvDTE::ProjectItemPtr(NULL); for (short i = 1; i <= Count; i++) { EnvDTE::ProjectItemPtr pItem; pItems->Item(_variant_t(i), &pItem); _bstr_t IName; //pItem->get_Name(IName.GetAddress()); pItem->get_FileNames(i,IName.GetAddress()); /* if (!_wcsicmp(IName, ItemName)) { return pItem; } */ CString Name = (LPCTSTR)IName; ar.Add(Name); EnvDTE::ProjectItemPtr pItem2 = EnumItem(pProject, ar,pItem); if (pItem2 != NULL) return pItem2; } return EnvDTE::ProjectItemPtr(NULL); }
void LoadIgnoredID(CSimpleArray<int>& arrayIgnoredID) { arrayIgnoredID.RemoveAll(); CString strIgnoredIniPath; CAppPath::Instance().GetLeidianAppPath(strIgnoredIniPath); strIgnoredIniPath.Append(IGNORED_FILEPATH); CIniFile ini_IgnoredList(strIgnoredIniPath); CString strGetValue; ini_IgnoredList.GetStrValue(SEC_IGNOREDLIST_MAIN,KEY_IGNOREDLIST_COMMENT,strGetValue.GetBuffer(65536),65536); strGetValue.ReleaseBuffer(65536); WCHAR *szValue; WCHAR szTemp[10]; szValue = strGetValue.GetBuffer(); strGetValue.ReleaseBuffer(); WCHAR* p = wcstok(szValue,L"|"); while(p) { wcscpy_s(szTemp,p); arrayIgnoredID.Add(_wtoi(szTemp)); p = wcstok(NULL,L"|"); } }
void CUserPatcher::_FillRegInfo( INT nKBID, LPCTSTR szPatchName, LPCTSTR szProductKey, LPCTSTR szPatchKey, LPCTSTR szPatchValue, LPCTSTR szLogfile ) { LPCTSTR _key_patch = _T("Patches"); CString strProduct; strProduct.Format(_T("Installer\\Products\\%s\\Patches"), szProductKey); WriteRegString(HKEY_CLASSES_ROOT, strProduct, szPatchKey, szPatchValue); CSimpleArray<CString> ms; ReadRegMString(HKEY_CLASSES_ROOT, strProduct, _key_patch, ms); if( ms.Find(szPatchKey)==-1 ) { ms.Add( szPatchKey ); WriteRegMString(HKEY_CLASSES_ROOT, strProduct, _key_patch, ms); } // HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UserData\S-1-5-18\Products\4080110900063D11C8EF10054038389C\Patches\CEA540E1AE6DD1D41A6E01E6EF2B271C CString strPatchInfo; strPatchInfo.Format(_T("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\S-1-5-18\\Products\\%s\\Patches\\%s"), szProductKey, szPatchKey); CString strMoreInfoURL; FormatKBWebUrl( strMoreInfoURL, nKBID ); CString strDate; _GetDateString(strDate); WriteRegString(HKEY_LOCAL_MACHINE, strPatchInfo, _T("DisplayName"), szPatchName); WriteRegString(HKEY_LOCAL_MACHINE, strPatchInfo, _T("Installed"), strDate); WriteRegString(HKEY_LOCAL_MACHINE, strPatchInfo, _T("MoreInfoURL"), strMoreInfoURL); WriteRegDWord(HKEY_LOCAL_MACHINE, strPatchInfo, _T("LUAEnabled"), 0); WriteRegDWord(HKEY_LOCAL_MACHINE, strPatchInfo, _T("MSI3"), 1); WriteRegDWord(HKEY_LOCAL_MACHINE, strPatchInfo, _T("PatchType"), 0); WriteRegDWord(HKEY_LOCAL_MACHINE, strPatchInfo, _T("State"), 1); WriteRegDWord(HKEY_LOCAL_MACHINE, strPatchInfo, _T("Uninstallable"),0); }
BOOL CKSogoClean::ScanSogoPass() { if (!_CheckSogouExist()) { g_vsNoinstallapp.Add(SOGO_PASS); return TRUE; } BOOL bRet = FALSE; static BOOL bFlag = FALSE; std::wstring str; g_fnScanFile(g_pMain,BEGINPROC(SOGO_PASS),0,0,0); std::vector<std::wstring>::iterator it; for (it = g_listProcessName.begin(); it != g_listProcessName.end(); it++ ) { str = *it; transform(str.begin(), str.end(), str.begin(), towlower); if (str == L"sogouexplorer.exe") { str = L"正在运行,跳过"; goto clean0; } } str = L""; if (!bFlag) { str = L"可以清理"; bFlag = TRUE; } clean0: g_fnScanFile(g_pMain,ENDPROC(SOGO_PASS),str.c_str(),0,0); return bRet; }