diff options
Diffstat (limited to 'zen/privilege.cpp')
-rw-r--r-- | zen/privilege.cpp | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/zen/privilege.cpp b/zen/privilege.cpp index d4f956a8..98eaad43 100644 --- a/zen/privilege.cpp +++ b/zen/privilege.cpp @@ -3,6 +3,7 @@ #include "thread.h" //includes <boost/thread.hpp> #include "zstring.h" #include "scope_guard.h" +#include "win_ver.h" using namespace zen; @@ -68,9 +69,17 @@ void setPrivilege(LPCTSTR privilege, bool enable) //throw FileError nullptr)) //__out_opt PDWORD ReturnLength throw FileError(replaceCpy(_("Cannot set privilege %x."), L"%x", std::wstring(L"\"") + privilege + L"\""), formatSystemError(L"AdjustTokenPrivileges", getLastError())); - const ErrorCode lastError = getLastError(); + ErrorCode lastError = getLastError(); if (lastError == ERROR_NOT_ALL_ASSIGNED) //check although previous function returned with success! + { +#ifdef __MINGW32__ //Shobjidl.h +#define ERROR_ELEVATION_REQUIRED 740L +#endif + if (vistaOrLater()) //replace this useless error code with what it *really* means! + lastError = ERROR_ELEVATION_REQUIRED; + throw FileError(replaceCpy(_("Cannot set privilege %x."), L"%x", std::wstring(L"\"") + privilege + L"\""), formatSystemError(L"AdjustTokenPrivileges", lastError)); + } } |