diff options
author | Daniel Wilhelm <daniel@wili.li> | 2014-04-18 17:14:37 +0200 |
---|---|---|
committer | Daniel Wilhelm <daniel@wili.li> | 2014-04-18 17:14:37 +0200 |
commit | 8bf668665b107469086f16cb8ad23e47d479d2b4 (patch) | |
tree | 66a91ef06a8caa7cd6819dcbe1860693d3eda8d5 /shared/privilege.cpp | |
parent | 3.21 (diff) | |
download | FreeFileSync-8bf668665b107469086f16cb8ad23e47d479d2b4.tar.gz FreeFileSync-8bf668665b107469086f16cb8ad23e47d479d2b4.tar.bz2 FreeFileSync-8bf668665b107469086f16cb8ad23e47d479d2b4.zip |
4.0
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( |