BOOL CAuthDlg::OnInitDialog() { CDialog::OnInitDialog(); CWinApp* pApp = AfxGetApp(); if (pApp->m_pszRegistryKey) { CRegKey hSecKey(pApp->GetSectionKey(IDS_R_LOGINS)); if (hSecKey) { int i = 0; TCHAR username[256], password[256]; for (;;) { DWORD unlen = _countof(username); DWORD pwlen = sizeof(password); DWORD type = REG_SZ; if (ERROR_SUCCESS == RegEnumValue(hSecKey, i++, username, &unlen, 0, &type, (BYTE*)password, &pwlen)) { m_logins[username] = DEncrypt(password); m_usernamectrl.AddString(username); } else { break; } } } } else { CAutoVectorPtr<TCHAR> buff; buff.Allocate(32767/sizeof(TCHAR)); DWORD len = GetPrivateProfileSection(IDS_R_LOGINS, buff, 32767/sizeof(TCHAR), pApp->m_pszProfileName); TCHAR* p = buff; while (*p && len > 0) { CString str = p; p += str.GetLength()+1; len -= str.GetLength()+1; CAtlList<CString> sl; Explode(str, sl, '=', 2); if (sl.GetCount() == 2) { m_logins[sl.GetHead()] = DEncrypt(sl.GetTail()); m_usernamectrl.AddString(sl.GetHead()); } } } m_usernamectrl.SetFocus(); return TRUE; }
static bool SearchFiles(CString mask, CAtlList<CString>& sl) { if (mask.Find(_T("://")) >= 0) { return false; } mask.Trim(); sl.RemoveAll(); CMediaFormats& mf = AfxGetAppSettings().m_Formats; WIN32_FILE_ATTRIBUTE_DATA fad; bool fFilterKnownExts = (GetFileAttributesEx(mask, GetFileExInfoStandard, &fad) && (fad.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)); if (fFilterKnownExts) { mask = CString(mask).TrimRight(_T("\\/")) + _T("\\*.*"); } { CString dir = mask.Left(max(mask.ReverseFind('\\'), mask.ReverseFind('/')) + 1); WIN32_FIND_DATA fd; HANDLE h = FindFirstFile(mask, &fd); if (h != INVALID_HANDLE_VALUE) { do { if (fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) { continue; } CString fn = fd.cFileName; //CString ext = fn.Mid(fn.ReverseFind('.')+1).MakeLower(); CString ext = fn.Mid(fn.ReverseFind('.')).MakeLower(); CString path = dir + fd.cFileName; if (!fFilterKnownExts || mf.FindExt(ext)) { for (size_t i = 0; i < mf.GetCount(); i++) { CMediaFormatCategory& mfc = mf.GetAt(i); /* playlist files are skipped when playing the contents of an entire directory */ if ((mfc.FindExt(ext)) && (mf[i].GetLabel().CompareNoCase(_T("pls")) != 0)) { sl.AddTail(path); break; } } } } while (FindNextFile(h, &fd)); FindClose(h); if (sl.GetCount() == 0 && mask.Find(_T(":\\")) == 1) { GetCDROMType(mask[0], sl); } } } return (sl.GetCount() > 1 || sl.GetCount() == 1 && sl.GetHead().CompareNoCase(mask) || sl.GetCount() == 0 && mask.FindOneOf(_T("?*")) >= 0); }
void CPlayerPlaylistBar::ParsePlayList(CAtlList<CString>& fns, CAtlList<CString>* subs) { if (fns.IsEmpty()) { return; } const CAppSettings& s = AfxGetAppSettings(); ResolveLinkFiles(fns); CAtlList<CString> sl; if (SearchFiles(fns.GetHead(), sl)) { if (sl.GetCount() > 1) { subs = NULL; } POSITION pos = sl.GetHeadPosition(); while (pos) { ParsePlayList(sl.GetNext(pos), subs); } return; } CAtlList<CString> redir; CStringA ct = GetContentType(fns.GetHead(), &redir); if (!redir.IsEmpty()) { POSITION pos = redir.GetHeadPosition(); while (pos) { ParsePlayList(sl.GetNext(pos), subs); } return; } if (ct == "application/x-mpc-playlist") { ParseMPCPlayList(fns.GetHead()); return; } else { #if INTERNAL_SOURCEFILTER_MPEG if (ct == "application/x-bdmv-playlist" && s.SrcFilters[SRC_MPEG]) { ParseBDMVPlayList(fns.GetHead()); return; } #endif } AddItem(fns, subs); }
void CFavoriteOrganizeDlg::SetupList(bool fSave) { int i = m_tab.GetCurSel(); if (fSave) { CAtlList<CString> sl; for (int j = 0; j < m_list.GetItemCount(); j++) { CAtlList<CString> args; ExplodeEsc(m_sl[i].GetAt((POSITION)m_list.GetItemData(j)), args, _T(';')); args.RemoveHead(); args.AddHead(m_list.GetItemText(j, 0)); sl.AddTail(ImplodeEsc(args, _T(';'))); } m_sl[i].RemoveAll(); m_sl[i].AddTailList(&sl); } else { m_list.DeleteAllItems(); POSITION pos = m_sl[i].GetHeadPosition(), tmp; while (pos) { tmp = pos; CAtlList<CString> sl; ExplodeEsc(m_sl[i].GetNext(pos), sl, _T(';'), 3); int n = m_list.InsertItem(m_list.GetItemCount(), sl.RemoveHead()); m_list.SetItemData(n, (DWORD_PTR)tmp); if (!sl.IsEmpty()) { REFERENCE_TIME rt = 0; if (1 == _stscanf_s(sl.GetHead(), _T("%I64d"), &rt) && rt > 0) { DVD_HMSF_TIMECODE hmsf = RT2HMSF(rt); CString str; str.Format(_T("[%02d:%02d:%02d]"), hmsf.bHours, hmsf.bMinutes, hmsf.bSeconds); m_list.SetItemText(n, 1, str); } } } UpdateColumnsSizes(); } }
// Define the integer list CAtlList<int> myList; // Populate the list POSITION myPos = myList.AddHead(1); myPos = myList.InsertBefore(myPos, 2); myPos = myList.InsertBefore(myPos, 3); // Confirm the head value is as expected ATLASSERT(myList.GetHead() == 3);
// Define the integer list CAtlList<int> myList; // Populate the list myList.AddTail(100); myList.AddTail(200); myList.AddTail(300); // Confirm the head of the list ATLASSERT(myList.GetHead() == 100); // Remove the head of the list ATLASSERT(myList.RemoveHead() == 100); // Confirm the new head of the list ATLASSERT(myList.GetHead() == 200);