Changeset 398
- Timestamp:
- 9/26/2008 4:57:59 AM (5 years ago)
- File:
-
- 1 edited
-
trunk/Eraser.cpp (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Eraser.cpp
r363 r398 76 76 // registered so that we can unregister it in ExitInstance 77 77 static BOOL bClassRegistered = FALSE; 78 __declspec(dllimport) bool IsProcessElevated(HANDLE process); 78 79 79 80 BOOL CEraserApp::FirstInstance() 80 81 { 81 CWnd *pWndPrev = CWnd::FindWindow(szEraserClassName, NULL);82 CWnd *pWndPrev = CWnd::FindWindow(szEraserClassName, NULL); 82 83 CWnd *pWndChild; 83 84 … … 85 86 if (pWndPrev) 86 87 { 88 // Determine the elevation status of both processes. 89 unsigned elevationStatus = 0; 90 { 91 DWORD pid = 0; 92 GetWindowThreadProcessId(pWndPrev->m_hWnd, &pid); 93 HANDLE process = OpenProcess(PROCESS_QUERY_INFORMATION, false, pid); 94 if (IsProcessElevated(process)) 95 elevationStatus |= 2; 96 if (IsProcessElevated(GetCurrentProcess())) 97 elevationStatus |= 1; 98 } 99 100 if (!(elevationStatus & 2) && (elevationStatus & 1)) 101 { 102 switch (AfxMessageBox("Another instance of Eraser is still running, but this " 103 "new instance is running at a higher privilege level than the other.\n\n" 104 "Do you want to close the previous instance? " 105 "All active erasing tasks will be terminated", MB_YESNO)) 106 { 107 case IDYES: 108 pWndPrev->SendMessage(WM_CLOSE); 109 break; 110 } 111 112 return TRUE; 113 } 114 87 115 // if so, does it have any popups? 88 116 pWndChild = pWndPrev->GetLastActivePopup();
Note: See TracChangeset
for help on using the changeset viewer.
