Changeset 715
- Timestamp:
- 12/05/08 04:37:43 (4 years ago)
- Location:
- branches/eraser6/ShellExt
- Files:
-
- 4 edited
-
CtxMenu.cpp (modified) (6 diffs)
-
CtxMenu.h (modified) (3 diffs)
-
ShellExt_i.c (modified) (1 diff)
-
ShellExt_i.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
branches/eraser6/ShellExt/CtxMenu.cpp
r711 r715 25 25 #include <sstream> 26 26 27 extern "C" 28 { 29 typedef LONG NTSTATUS; 30 enum KEY_INFORMATION_CLASS 31 { 32 KeyBasicInformation, 33 KeyNodeInformation, 34 KeyFullInformation, 35 KeyNameInformation, 36 KeyCachedInformation, 37 KeyVirtualizationInformation 38 }; 39 40 struct KEY_BASIC_INFORMATION 41 { 42 LARGE_INTEGER LastWriteTime; 43 ULONG TitleIndex; 44 ULONG NameLength; 45 WCHAR Name[1]; 46 }; 47 48 typedef NTSTATUS (*pZwQueryKey)(HANDLE KeyHandle, KEY_INFORMATION_CLASS KeyInformationClass, 49 PVOID KeyInformation, ULONG Length, PULONG ResultLength); 50 pZwQueryKey ZwQueryKey; 51 } 52 27 53 template<typename handleType> class Handle 28 54 { … … 51 77 52 78 HRESULT CCtxMenu::Initialize(LPCITEMIDLIST pidlFolder, LPDATAOBJECT pDataObj, 53 HKEY /*hProgID*/) 54 { 55 m_itemID = 0; 56 FORMATETC fmt = { CF_HDROP, NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL }; 57 STGMEDIUM stg = { TYMED_HGLOBAL }; 58 HDROP hDrop; 59 60 //Check pidlFolder for the drop path, if it exists. 61 if (pidlFolder != NULL) 62 { 79 HKEY hProgID) 80 { 81 //Initialise member variables. 82 m_itemID = 0; 83 84 //Determine where the shell extension was invoked from. 85 if (GetHKeyPath(hProgID) == L"{645FF040-5081-101B-9F08-00AA002F954E}") 86 { 87 InvokeReason = INVOKEREASON_RECYCLEBIN; 88 89 //We can't do much other processing: the LPDATAOBJECT parameter contains 90 //data that is a private type so we don't know how to query for it. 91 return S_OK; 92 } 93 94 //Check pidlFolder for the drop path, if it exists. This is for drag-and-drop 95 //context menus. 96 else if (pidlFolder != NULL) 97 { 98 InvokeReason = INVOKEREASON_DRAGDROP; 99 63 100 //Translate the drop path to a location on the filesystem. 64 101 wchar_t dropTargetPath[MAX_PATH]; … … 69 106 } 70 107 108 //Okay, everything else is a simple context menu for a set of selected files/ 109 //folders/drives. 110 else 111 InvokeReason = INVOKEREASON_FILEFOLDER; 112 71 113 //Look for CF_HDROP data in the data object. 114 FORMATETC fmt = { CF_HDROP, NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL }; 115 STGMEDIUM stg = { TYMED_HGLOBAL }; 72 116 if (FAILED(pDataObj->GetData(&fmt, &stg))) 73 117 //Nope! Return an "invalid argument" error back to Explorer. 74 return E_INVALIDARG;118 return S_OK; 75 119 76 120 //Get a pointer to the actual data. 77 hDrop = static_cast<HDROP>(GlobalLock(stg.hGlobal)); 78 79 //Make sure it worked. 121 HDROP hDrop = static_cast<HDROP>(GlobalLock(stg.hGlobal)); 80 122 if (hDrop == NULL) 81 123 return E_INVALIDARG; … … 90 132 } 91 133 134 //Collect all the files which have been selected. 92 135 HRESULT hr = S_OK; 93 136 WCHAR buffer[MAX_PATH] = {0}; … … 104 147 } 105 148 149 //Clean up. 106 150 GlobalUnlock(stg.hGlobal); 107 151 ReleaseStgMedium(&stg); 108 152 return hr; 109 153 } 110 /*111 +-------------------+112 | |113 | |114 | |115 | |116 +-------------------+ +-------------------+117 |(ICON) Eraser v6 > | | Erase selected | //--> erase the files immediately using defaults118 +-------------------+ | Schedule Selected | //--> open the scheduler menu, with files/folders filled in119 | | +-------------------+120 | | | Secure move | //--> secure move the files121 | | +-------------------+ // Eraser.Manager Algorithms popup122 | | |(*) Customise | // set algorithm for this query only123 +-------------------+ +-------------------+124 */125 154 126 155 HRESULT CCtxMenu::QueryContextMenu(HMENU hmenu, UINT uMenuIndex, UINT uidFirstCmd, … … 534 563 } 535 564 565 std::wstring CCtxMenu::GetHKeyPath(HKEY handle) 566 { 567 ZwQueryKey = reinterpret_cast<pZwQueryKey>(GetProcAddress( 568 LoadLibrary(L"Ntdll.dll"), "ZwQueryKey")); 569 ULONG keyInfoSize = sizeof(KEY_BASIC_INFORMATION); 570 KEY_BASIC_INFORMATION* keyInfo = NULL; 571 NTSTATUS queryResult = ERROR_MORE_DATA; 572 573 while (queryResult == ERROR_MORE_DATA) 574 { 575 delete[] keyInfo; 576 keyInfo = reinterpret_cast<KEY_BASIC_INFORMATION*>( 577 new char[keyInfoSize += 512]); 578 ::ZeroMemory(keyInfo, keyInfoSize); 579 queryResult = ZwQueryKey(handle, KeyBasicInformation, keyInfo, 580 keyInfoSize, &keyInfoSize); 581 } 582 583 std::wstring result(keyInfo->Name, keyInfoSize - 584 sizeof(KEY_BASIC_INFORMATION) + 1); 585 delete[] keyInfo; 586 return result; 587 } 588 536 589 MENUITEMINFO* CCtxMenu::GetSeparator() 537 590 { -
branches/eraser6/ShellExt/CtxMenu.h
r711 r715 49 49 } 50 50 51 /// The place where the context menu extension was invoked. 52 enum InvokeReasons 53 { 54 INVOKEREASON_FILEFOLDER, 55 INVOKEREASON_DRAGDROP, 56 INVOKEREASON_RECYCLEBIN 57 }; 58 51 59 enum CEraserLPVERBS 52 60 { … … 75 83 CEraserLPVERBS GetApplicableActions(); 76 84 85 static std::wstring GetHKeyPath(HKEY handle); 77 86 static MENUITEMINFO* GetSeparator(); 78 87 static HICON GetMenuIcon(); … … 81 90 82 91 protected: 92 InvokeReasons InvokeReason; 93 83 94 UINT m_itemID; 84 95 string_list m_szSelectedFiles; -
branches/eraser6/ShellExt/ShellExt_i.c
r712 r715 7 7 8 8 /* File created by MIDL compiler version 7.00.0500 */ 9 /* at Tue Dec 02 22:04:2120089 /* at Fri Dec 05 11:15:23 2008 10 10 */ 11 11 /* Compiler settings for .\DllMain.idl: 12 Oicf, W1, Zp8, env=Win 64(32b run)12 Oicf, W1, Zp8, env=Win32 (32b run) 13 13 protocol : dce , ms_ext, c_ext, robust 14 error checks: allocation ref bounds_check enumstub_data14 error checks: stub_data 15 15 VC __declspec() decoration level: 16 16 __declspec(uuid()), __declspec(selectany), __declspec(novtable) -
branches/eraser6/ShellExt/ShellExt_i.h
r712 r715 5 5 6 6 /* File created by MIDL compiler version 7.00.0500 */ 7 /* at Tue Dec 02 22:04:2120087 /* at Fri Dec 05 11:15:23 2008 8 8 */ 9 9 /* Compiler settings for .\DllMain.idl: 10 Oicf, W1, Zp8, env=Win 64(32b run)10 Oicf, W1, Zp8, env=Win32 (32b run) 11 11 protocol : dce , ms_ext, c_ext, robust 12 error checks: allocation ref bounds_check enumstub_data12 error checks: stub_data 13 13 VC __declspec() decoration level: 14 14 __declspec(uuid()), __declspec(selectany), __declspec(novtable)
Note: See TracChangeset
for help on using the changeset viewer.
