1 #ifndef _SHELLFIND_PCH_ 2 #define _SHELLFIND_PCH_ 3 4 #define WIN32_NO_STATUS 5 #define _INC_WINDOWS 6 #define COM_NO_WINDOWS_H 7 8 #include <windef.h> 9 #include <winbase.h> 10 #include <shlobj.h> 11 #include <shlobj_undoc.h> 12 #include <shlguid_undoc.h> 13 #include <shdeprecated.h> 14 #include <tchar.h> 15 #include <atlbase.h> 16 #include <atlcom.h> 17 #include <atlwin.h> 18 #include <atlsimpcoll.h> 19 #include <atlstr.h> 20 #include <shlwapi.h> 21 #include <shlwapi_undoc.h> 22 #include <undocshell.h> 23 #include <shellutils.h> 24 #include <strsafe.h> 25 #include <wine/debug.h> 26 27 #include "../resource.h" 28 29 #define WM_SEARCH_START WM_USER + 0 30 #define WM_SEARCH_STOP WM_USER + 1 31 #define WM_SEARCH_ADD_RESULT WM_USER + 2 32 #define WM_SEARCH_UPDATE_STATUS WM_USER + 3 33 34 typedef struct tagLOCATIONITEM 35 { 36 struct tagLOCATIONITEM *pNext; 37 WCHAR szPath[ANYSIZE_ARRAY]; 38 } LOCATIONITEM; 39 40 void FreeList(LOCATIONITEM *pLI); 41 42 struct ScopedFreeLocationItems 43 { 44 LOCATIONITEM *m_ptr; 45 ScopedFreeLocationItems(LOCATIONITEM *ptr) : m_ptr(ptr) {} 46 ~ScopedFreeLocationItems() { FreeList(m_ptr); } 47 void Detach() { m_ptr = NULL; } 48 }; 49 50 struct SearchStart 51 { 52 LOCATIONITEM *pPaths; 53 WCHAR szFileName[MAX_PATH]; 54 WCHAR szQuery[MAX_PATH]; 55 BOOL SearchHidden; 56 }; 57 58 template<class T, class F, class R> 59 static INT_PTR FindItemInComboEx(HWND hCombo, T &FindItem, F CompareFunc, R RetMatch) 60 { 61 COMBOBOXEXITEMW item; 62 item.mask = CBEIF_LPARAM; 63 item.cchTextMax = 0; 64 for (item.iItem = 0; SendMessageW(hCombo, CBEM_GETITEMW, 0, (LPARAM)&item); item.iItem++) 65 { 66 if (CompareFunc((T&)item.lParam, FindItem) == RetMatch) 67 return item.iItem; 68 } 69 return -1; 70 } 71 72 static inline bool PathIsOnDrive(PCWSTR Path) 73 { 74 return PathGetDriveNumberW(Path) >= 0 && (Path[2] == '\\' || !Path[2]); 75 } 76 77 static inline BOOL PathIsOnUnc(PCWSTR Path) 78 { 79 return PathIsUNCW(Path); // FIXME: Verify the path starts with <\\Server\Share>[\] 80 } 81 82 static inline bool PathIsAbsolute(PCWSTR Path) 83 { 84 // Note: PathIsRelativeW is too forgiving 85 return PathIsOnDrive(Path) || PathIsOnUnc(Path); 86 } 87 88 #endif /* _SHELLFIND_PCH_ */ 89