Вот решение VB6, чтобы проверить, повышен ли текущий процесс;должно быть достаточно легко перевести на C ++.
Public Function IsCurrentProcessElevated() As Boolean
Dim lRet As Long, pAdministratorsGroup As Long
Dim udtSidIdentifierAuthority As SID_IDENTIFIER_AUTHORITY
udtSidIdentifierAuthority.Value(5) = 5 ' SECURITY_NT_AUTHORITY
lRet = AllocateAndInitializeSid(udtSidIdentifierAuthority, 2, SECURITY_BUILTIN_DOMAIN_RID, DOMAIN_ALIAS_RID_ADMINS, 0, 0, 0, 0, 0, 0, pAdministratorsGroup)
If lRet <> 0 Then
If CheckTokenMembership(0, pAdministratorsGroup, lRet) <> 0 Then ' Use 0 to check the calling thread
IsCurrentProcessElevated = (lRet <> 0)
End If
' Note: This line was often crashing in Windows 7, fix was to change the API declare to recieve argument ByVal
' /954215/checktokenmembership-v-vb6-sboi-freesid-v-windows-7-i-windows-2008
Call FreeSid(pAdministratorsGroup)
End If
End Function