Changeset 698
- Timestamp:
- 12/2/2008 11:45:04 AM (4 years ago)
- Location:
- branches/erasershellext/cpp
- Files:
-
- 2 edited
-
CtxMenu.cpp (modified) (7 diffs)
-
CtxMenu.h (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/erasershellext/cpp/CtxMenu.cpp
r696 r698 47 47 48 48 namespace Eraser { 49 const wchar_t* CCtxMenu::m_szMenuTitle = L"Eraser v6";49 const wchar_t* CCtxMenu::m_szMenuTitle = L"Eraser"; 50 50 51 51 HRESULT CCtxMenu::Initialize(LPCITEMIDLIST /*pidlFolder*/, LPDATAOBJECT pDataObj, … … 79 79 80 80 HRESULT hr = S_OK; 81 WCHAR Buffer[MAX_PATH] = {0}; 82 for (UINT i = uNumFiles; i < uNumFiles; i++) 83 { 84 //TODO: Collect the list of files queried. 85 UINT charsWritten = DragQueryFile(hDrop, i, Buffer, sizeof(Buffer) / sizeof(Buffer[0])); 81 WCHAR buffer[MAX_PATH] = {0}; 82 for (UINT i = 0; i < uNumFiles; i++) 83 { 84 UINT charsWritten = DragQueryFile(hDrop, i, buffer, sizeof(buffer) / sizeof(buffer[0])); 86 85 if (!charsWritten) 86 { 87 87 hr = E_INVALIDARG; 88 else 89 PathQuoteSpaces(Buffer); 88 continue; 89 } 90 91 m_szSelectedFiles.push_back(std::wstring(buffer, charsWritten)); 90 92 } 91 93 … … 121 123 HMENU hSubmenu = CreatePopupMenu(); 122 124 123 //Create the submenu, following the order defined in the CEraserLPVERB enum 124 InsertMenu (hSubmenu, CERASER_ERASE, MF_BYPOSITION, uID++, _T("&Erase")); 125 InsertMenu (hSubmenu, CERASER_SCHEDULE, MF_BYPOSITION, uID++, _T("&Schedule")); 126 InsertMenu (hSubmenu, CERASER_ERASE_ON_RESTART, MF_BYPOSITION, uID++, _T("Erase on &Restart")); 125 //Create the submenu, following the order defined in the CEraserLPVERB enum, creating 126 //only items which are applicable. 127 CEraserLPVERBS applicableVerbs = GetApplicableActions(); 128 if (applicableVerbs & CERASER_ERASE) 129 InsertMenu (hSubmenu, CERASER_ERASE, MF_BYPOSITION, uID++, _T("&Erase")); 130 if (applicableVerbs & CERASER_ERASE_ON_RESTART) 131 InsertMenu (hSubmenu, CERASER_ERASE_ON_RESTART, MF_BYPOSITION, uID++, _T("Erase on &Restart")); 132 if (applicableVerbs & CERASER_ERASE_UNUSED_SPACE) 133 InsertMenu (hSubmenu, CERASER_ERASE_UNUSED_SPACE, MF_BYPOSITION, uID++, _T("Erase &Unused Space")); 127 134 //------------------------------------------------------------------------- 128 InsertMenuItem(hSubmenu, CERASER_SEPERATOR_1, TRUE, GetSeparator());129 InsertMenu (hSubmenu, CERASER_SECURE_MOVE, MF_BYPOSITION, uID++, _T("Secure &Move"));130 //-------------------------------------------------------------------------131 InsertMenuItem(hSubmenu, CERASER_SEPERATOR_2, TRUE, GetSeparator());132 InsertMenu (hSubmenu, CERASER_CUSTOMISE, MF_BYPOSITION, uID++, _T("&Console"));135 if (applicableVerbs & CERASER_SECURE_MOVE) 136 { 137 InsertMenuItem(hSubmenu, CERASER_SEPERATOR_1, TRUE, GetSeparator()); 138 InsertMenu (hSubmenu, CERASER_SECURE_MOVE, MF_BYPOSITION, uID++, _T("Secure &Move")); 139 } 133 140 134 141 //Insert the submenu into the Context menu provided by Explorer. … … 347 354 string_type command(L"eraser "); 348 355 string_type files, directories, unuseds; 349 356 #if 0 350 357 // compile the eraser command syntax 351 358 for (string_list::const_iterator i = m_szSelectedFiles.begin(); … … 368 375 switch(LOWORD(pCmdInfo->lpVerb + 1)) 369 376 { 370 #if 0371 377 case CERASER_ERASE: 372 378 { … … 401 407 break; 402 408 } 403 #endif404 409 default: 405 410 { … … 408 413 MessageBox ( pCmdInfo->hwnd, szMsg, _T("Eraser v6 - Shell Extention Query"), MB_ICONINFORMATION ); 409 414 } 410 return result; 411 } 415 } 416 #endif 417 return result; 418 } 419 420 CCtxMenu::CEraserLPVERBS CCtxMenu::GetApplicableActions() 421 { 422 unsigned result = CERASER_ERASE | CERASER_ERASE_ON_RESTART | CERASER_SECURE_MOVE | 423 CERASER_ERASE_UNUSED_SPACE; 424 for (std::list<std::wstring>::const_iterator i = m_szSelectedFiles.begin(); 425 i != m_szSelectedFiles.end(); ++i) 426 { 427 //Remove trailing slashes if they are directories. 428 std::wstring item(*i); 429 //if (item.length() > 3 && item[item.length() - 1] == '\'') 430 // item.erase(item.begin() + item.length() - 1); 431 432 //Check if the path is a path to a volume, if it is not, remove the 433 //erase unused space verb. 434 wchar_t volumeName[MAX_PATH]; 435 if (!GetVolumeNameForVolumeMountPoint(item.c_str(), volumeName, 436 sizeof(volumeName) / sizeof(volumeName[0]))) 437 { 438 result &= ~CERASER_ERASE_UNUSED_SPACE; 439 } 440 } 441 442 return static_cast<CEraserLPVERBS>(result); 412 443 } 413 444 -
branches/erasershellext/cpp/CtxMenu.h
r696 r698 38 38 typedef std::list<string_type> string_list; 39 39 40 enum CEraserSecureMove41 {42 INV_SRC_FILE,43 INV_DST_FILE,44 };45 46 static int SecureMove(const std::wstring& dst, const std::wstring& src)47 {48 //CFile file(49 // CreateFile(50 // src.c_str(),51 // FILE_GENERIC_READ|FILE_GENERIC_WRITE,52 // FILE_SHARE_READ|FILE_SHARE_WRITE,53 // NULL,54 // OPEN_EXISTING,55 // 0,56 // NULL)57 // );58 59 if (!CopyFile(src.c_str(), dst.c_str(), FALSE))60 {61 //file.Close();62 return GetLastError();63 }64 65 // successfull copy, add for erasure66 }67 68 40 class ATL_NO_VTABLE CCtxMenu : 69 41 public CComObjectRootEx<CComSingleThreadModel>, … … 79 51 enum CEraserLPVERBS 80 52 { 81 CERASER_ERASE =0,82 CERASER_ SCHEDULE,83 CERASER_ERASE_ ON_RESTART,53 CERASER_ERASE = 1 << 0, 54 CERASER_ERASE_ON_RESTART = 1 << 1, 55 CERASER_ERASE_UNUSED_SPACE = 1 << 2, 84 56 CERASER_SEPERATOR_1, 85 CERASER_SECURE_MOVE, 86 CERASER_SEPERATOR_2, 87 CERASER_CUSTOMISE 57 CERASER_SECURE_MOVE = 1 << 3, 88 58 }; 89 59 … … 103 73 bool OnDrawItem(HDC hdc, RECT rect, UINT action, UINT state); 104 74 75 CEraserLPVERBS GetApplicableActions(); 76 105 77 static MENUITEMINFO* GetSeparator(); 106 78 static HICON GetMenuIcon(); … … 111 83 UINT m_itemID; 112 84 string_list m_szSelectedFiles; 113 string_list m_szSelectedDirectories;114 string_list m_szSelectedUnused;115 85 116 86 static const wchar_t* m_szMenuTitle;
Note: See TracChangeset
for help on using the changeset viewer.
