Título: Como resolver este error
Publicado por: Borito30 en 28 Febrero 2017, 18:00 pm
Me da el siguiente error: ||=== Build: Debug in main (compiler: GNU GCC Compiler) ===| C:\Users\Androide\Desktop\main.cpp||In function 'BOOL IsElevated()':| C:\Users\Androide\Desktop\main.cpp|13|error: 'Elevation' does not name a type| C:\Users\Androide\Desktop\main.cpp|14|error: 'TOKEN_ELEVATION' was not declared in this scope| C:\Users\Androide\Desktop\main.cpp|15|error: 'TokenElevation' was not declared in this scope| C:\Users\Androide\Desktop\main.cpp|16|error: request for member 'TokenIsElevated' in 'Elevation', which is of non-class type 'DWORD {aka long unsigned int}'| C:\Users\Androide\Desktop\main.cpp|10|warning: unused variable 'Elevation' [-Wunused-variable]| ||=== Build failed: 4 error(s), 1 warning(s) (0 minute(s), 2 second(s)) ===| #include <iostream> #include <windows.h> #include <winnt.h>
using namespace std;
BOOL IsElevated( ) { BOOL fRet = FALSE; HANDLE hToken = NULL; DWORD Elevation; if( OpenProcessToken( GetCurrentProcess( ),TOKEN_QUERY,&hToken ) ) { DWORD Elevation; typedef Elevation TOKEN_ELEVATION; DWORD cbSize = sizeof( TOKEN_ELEVATION ); if( GetTokenInformation( hToken, TokenElevation, &Elevation, sizeof( Elevation ), &cbSize ) ) { fRet = Elevation.TokenIsElevated; } } if( hToken ) { CloseHandle( hToken ); } return fRet; }
int main() { bool valor=IsElevated( );
if(valor==true){ cout << "Tienes permisos de administrador"; }else{ cout << "Eres un usuario corriente"; } system("pause"); return 0; }
Título: Re: Como resolver este error
Publicado por: ivancea96 en 2 Marzo 2017, 08:53 am
En primer lugar, con typedef, coo dice su nombre, defines tpos. Elevation no es un tpo e suna variable.
Luego: Elevation.TokenIsElevated. Elevation e sun DWORD, ¿cómo podría tener un campo "TokenIsElevated"?
|