1
0
mirror of https://github.com/wolfpld/tracy.git synced 2025-03-20 07:40:02 +08:00

Check elevation status on Windows.

This commit is contained in:
Bartosz Taudul
2022-11-27 21:48:20 +01:00
parent e1395f5a53
commit 7e23d873dc
4 changed files with 46 additions and 0 deletions
+32
View File
@@ -0,0 +1,32 @@
#include "IsElevated.hpp"
#ifdef _WIN32
#include <windows.h>
bool IsElevated()
{
HANDLE token;
if( OpenProcessToken( GetCurrentProcess(), TOKEN_QUERY, &token ) == 0 ) return false;
TOKEN_ELEVATION te;
DWORD sz;
if( GetTokenInformation( token, TokenElevation, &te, sizeof( te ), &sz ) == 0 )
{
CloseHandle( token );
return false;
}
bool ret = te.TokenIsElevated;
CloseHandle( token );
return ret;
}
#else
bool IsElevated()
{
return false;
}
#endif