mirror of
https://github.com/reactos/reactos.git
synced 2025-08-02 05:25:48 +00:00
[SHELLFIND] Add Hidden Files & Folders Selection. CORE-16427
This commit is contained in:
parent
c290ae21c7
commit
103c87d2b9
25 changed files with 358 additions and 193 deletions
|
@ -160,6 +160,7 @@ struct _SearchData
|
|||
CStringW szFileName;
|
||||
CStringA szQueryA;
|
||||
CStringW szQueryW;
|
||||
BOOL SearchHidden;
|
||||
CComPtr<CFindFolder> pFindFolder;
|
||||
};
|
||||
|
||||
|
@ -235,6 +236,33 @@ static UINT SearchFile(LPCWSTR lpFilePath, _SearchData *pSearchData)
|
|||
return uMatches;
|
||||
}
|
||||
|
||||
static BOOL FileNameMatch(LPCWSTR FindDataFileName, _SearchData *pSearchData)
|
||||
{
|
||||
if (pSearchData->szFileName.IsEmpty() || PathMatchSpecW(FindDataFileName, pSearchData->szFileName))
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static BOOL ContentsMatch(LPCWSTR szPath, _SearchData *pSearchData)
|
||||
{
|
||||
if (pSearchData->szQueryA.IsEmpty() || SearchFile(szPath, pSearchData))
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static BOOL AttribHiddenMatch(DWORD FileAttributes, _SearchData *pSearchData)
|
||||
{
|
||||
if (!(FileAttributes & FILE_ATTRIBUTE_HIDDEN) || (pSearchData->SearchHidden))
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static UINT RecursiveFind(LPCWSTR lpPath, _SearchData *pSearchData)
|
||||
{
|
||||
if (WaitForSingleObject(pSearchData->hStopEvent, 0) != WAIT_TIMEOUT)
|
||||
|
@ -260,8 +288,8 @@ static UINT RecursiveFind(LPCWSTR lpPath, _SearchData *pSearchData)
|
|||
if (FindData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
|
||||
{
|
||||
CStringW status;
|
||||
if ((pSearchData->szFileName.IsEmpty() || PathMatchSpecW(FindData.cFileName, pSearchData->szFileName))
|
||||
&& (pSearchData->szQueryA.IsEmpty() || SearchFile(szPath, pSearchData)))
|
||||
if (FileNameMatch(FindData.cFileName, pSearchData)
|
||||
&& AttribHiddenMatch(FindData.dwFileAttributes, pSearchData))
|
||||
{
|
||||
PostMessageW(pSearchData->hwnd, WM_SEARCH_ADD_RESULT, 0, (LPARAM) StrDupW(szPath));
|
||||
uTotalFound++;
|
||||
|
@ -271,8 +299,9 @@ static UINT RecursiveFind(LPCWSTR lpPath, _SearchData *pSearchData)
|
|||
|
||||
uTotalFound += RecursiveFind(szPath, pSearchData);
|
||||
}
|
||||
else if ((pSearchData->szFileName.IsEmpty() || PathMatchSpecW(FindData.cFileName, pSearchData->szFileName))
|
||||
&& (pSearchData->szQueryA.IsEmpty() || SearchFile(szPath, pSearchData)))
|
||||
else if (FileNameMatch(FindData.cFileName, pSearchData)
|
||||
&& AttribHiddenMatch(FindData.dwFileAttributes, pSearchData)
|
||||
&& ContentsMatch(szPath, pSearchData))
|
||||
{
|
||||
uTotalFound++;
|
||||
PostMessageW(pSearchData->hwnd, WM_SEARCH_ADD_RESULT, 0, (LPARAM) StrDupW(szPath));
|
||||
|
@ -325,6 +354,11 @@ void CFindFolder::NotifyConnections(DISPID id)
|
|||
|
||||
LRESULT CFindFolder::StartSearch(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
|
||||
{
|
||||
HKEY hkey;
|
||||
DWORD size = sizeof(DWORD);
|
||||
DWORD result;
|
||||
DWORD SearchHiddenValue = 0;
|
||||
|
||||
if (!lParam)
|
||||
return 0;
|
||||
|
||||
|
@ -341,8 +375,36 @@ LRESULT CFindFolder::StartSearch(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &
|
|||
pSearchData->szFileName = pSearchParams->szFileName;
|
||||
pSearchData->szQueryA = pSearchParams->szQuery;
|
||||
pSearchData->szQueryW = pSearchParams->szQuery;
|
||||
pSearchData->SearchHidden = pSearchParams->SearchHidden;
|
||||
SHFree(pSearchParams);
|
||||
|
||||
TRACE("pSearchParams->SearchHidden is '%d'.\n", pSearchData->SearchHidden);
|
||||
|
||||
if (pSearchData->SearchHidden)
|
||||
SearchHiddenValue = 1;
|
||||
else
|
||||
SearchHiddenValue = 0;
|
||||
|
||||
/* Placing the code to save the changed settings to the registry here has the effect of not saving any changes */
|
||||
/* to the registry unless the user clicks on the "Search" button. This is the same as what we see in Windows. */
|
||||
result = RegOpenKeyEx(HKEY_CURRENT_USER, L"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer", 0, KEY_SET_VALUE, &hkey);
|
||||
if (result == ERROR_SUCCESS)
|
||||
{
|
||||
if (RegSetValueExW(hkey, L"SearchHidden", NULL, REG_DWORD, (const BYTE*)&SearchHiddenValue, size) == ERROR_SUCCESS)
|
||||
{
|
||||
TRACE("SearchHidden is '%d'.\n", SearchHiddenValue);
|
||||
}
|
||||
else
|
||||
{
|
||||
ERR("RegSetValueEx for \"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\SearchHidden\" Failed.\n");
|
||||
}
|
||||
RegCloseKey(hkey);
|
||||
}
|
||||
else
|
||||
{
|
||||
ERR("RegOpenKey for \"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\" Failed.\n");
|
||||
}
|
||||
|
||||
if (m_hStopEvent)
|
||||
SetEvent(m_hStopEvent);
|
||||
pSearchData->hStopEvent = m_hStopEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
|
||||
|
|
|
@ -32,6 +32,41 @@ CSearchBar::~CSearchBar()
|
|||
|
||||
LRESULT CSearchBar::OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
|
||||
{
|
||||
HKEY hkey;
|
||||
DWORD dwType;
|
||||
DWORD size = sizeof(DWORD);
|
||||
DWORD result;
|
||||
DWORD SearchHiddenValue = 0;
|
||||
|
||||
result = RegOpenKeyEx(HKEY_CURRENT_USER, L"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer", 0, KEY_QUERY_VALUE, &hkey);
|
||||
if (result == ERROR_SUCCESS)
|
||||
{
|
||||
if (RegQueryValueEx(hkey, L"SearchHidden", NULL, &dwType, (LPBYTE)&SearchHiddenValue, &size) == ERROR_SUCCESS)
|
||||
{
|
||||
if ((dwType != REG_DWORD) || (size != sizeof(DWORD)))
|
||||
{
|
||||
ERR("RegQueryKey for \"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\SearchHidden\" returned error(s).\n");
|
||||
SearchHiddenValue = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
TRACE("SearchHidden is '%d'.\n", SearchHiddenValue);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ERR("RegQueryKey for \"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\SearchHidden\" Failed.\n");
|
||||
}
|
||||
RegCloseKey(hkey);
|
||||
}
|
||||
else
|
||||
ERR("RegOpenKey for \"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\" Failed.\n");
|
||||
|
||||
if (SearchHiddenValue != 0)
|
||||
CheckDlgButton(IDC_SEARCH_HIDDEN, BST_CHECKED);
|
||||
else
|
||||
CheckDlgButton(IDC_SEARCH_HIDDEN, BST_UNCHECKED);
|
||||
|
||||
SetSearchInProgress(FALSE);
|
||||
|
||||
HWND hCombobox = GetDlgItem(IDC_SEARCH_COMBOBOX);
|
||||
|
@ -129,6 +164,9 @@ LRESULT CSearchBar::OnSearchButtonClicked(WORD wNotifyCode, WORD wID, HWND hWndC
|
|||
CComHeapPtr<SearchStart> pSearchStart(static_cast<SearchStart *>(CoTaskMemAlloc(sizeof(SearchStart))));
|
||||
GetDlgItemText(IDC_SEARCH_FILENAME, pSearchStart->szFileName, _countof(pSearchStart->szFileName));
|
||||
GetDlgItemText(IDC_SEARCH_QUERY, pSearchStart->szQuery, _countof(pSearchStart->szQuery));
|
||||
|
||||
pSearchStart->SearchHidden = IsDlgButtonChecked(IDC_SEARCH_HIDDEN);
|
||||
|
||||
if (!GetAddressEditBoxPath(pSearchStart->szPath))
|
||||
{
|
||||
ShellMessageBoxW(_AtlBaseModule.GetResourceInstance(), m_hWnd, MAKEINTRESOURCEW(IDS_SEARCHINVALID), MAKEINTRESOURCEW(IDS_SEARCHLABEL), MB_OK | MB_ICONERROR, pSearchStart->szPath);
|
||||
|
|
|
@ -36,6 +36,7 @@ struct SearchStart
|
|||
WCHAR szPath[MAX_PATH];
|
||||
WCHAR szFileName[MAX_PATH];
|
||||
WCHAR szQuery[MAX_PATH];
|
||||
BOOL SearchHidden;
|
||||
};
|
||||
|
||||
#endif /* _SHELLFIND_PCH_ */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue