diff options
Diffstat (limited to 'shared/privilege.cpp')
-rw-r--r-- | shared/privilege.cpp | 13 |
1 files changed, 4 insertions, 9 deletions
diff --git a/shared/privilege.cpp b/shared/privilege.cpp index eaeac866..6c7d951b 100644 --- a/shared/privilege.cpp +++ b/shared/privilege.cpp @@ -13,17 +13,14 @@ Privileges& Privileges::getInstance() } -bool Privileges::privilegeIsActive(LPCTSTR privilege) //throw (FileError) +bool Privileges::privilegeIsActive(LPCTSTR privilege) //throw FileError { HANDLE hToken = NULL; if (!::OpenProcessToken(::GetCurrentProcess(), //__in HANDLE ProcessHandle, TOKEN_QUERY, //__in DWORD DesiredAccess, &hToken)) //__out PHANDLE TokenHandle throw FileError(_("Error setting privilege:") + " \"" + privilege + "\"" + "\n\n" + getLastErrorFormatted()); - - Loki::ScopeGuard dummy = Loki::MakeGuard(::CloseHandle, hToken); - (void)dummy; //silence warning "unused variable" - + LOKI_ON_BLOCK_EXIT2(::CloseHandle(hToken)); LUID luid = {}; if (!::LookupPrivilegeValue( @@ -49,16 +46,14 @@ bool Privileges::privilegeIsActive(LPCTSTR privilege) //throw (FileError) } -void Privileges::setPrivilege(LPCTSTR privilege, bool enable) //throw (FileError) +void Privileges::setPrivilege(LPCTSTR privilege, bool enable) //throw FileError { HANDLE hToken = NULL; if (!::OpenProcessToken(::GetCurrentProcess(), //__in HANDLE ProcessHandle, TOKEN_ADJUST_PRIVILEGES, //__in DWORD DesiredAccess, &hToken)) //__out PHANDLE TokenHandle throw FileError(_("Error setting privilege:") + " \"" + privilege + "\"" + "\n\n" + getLastErrorFormatted()); - - Loki::ScopeGuard dummy = Loki::MakeGuard(::CloseHandle, hToken); - (void)dummy; //silence warning "unused variable" + LOKI_ON_BLOCK_EXIT2(::CloseHandle(hToken)); LUID luid = {}; if (!::LookupPrivilegeValue( |