Bonjour,
Comment déterminer si une appli à été lancée en mode User ou en mode Administrateur?
Merci
Version imprimable
Bonjour,
Comment déterminer si une appli à été lancée en mode User ou en mode Administrateur?
Merci
J'ai trouvé un exemple de code(voir plus bas). Je cherche encore le moyen d'augmenter les privilèges d'une appli (démarre en mode user et passe en mode administateur si c'est possible et si l'utilisateur l'autorise) si vous avez un exemple de code pour moi je suis preneur.
Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33 /*++ Routine Description: This routine returns TRUE if the caller's process is a member of the Administrators local group. Caller is NOT expected to be impersonating anyone and is expected to be able to open its own process and process token. Arguments: None. Return Value: TRUE - Caller has Administrators local group. FALSE - Caller does not have Administrators local group. -- */ BOOL IsUserAdmin(VOID) { BOOL b; SID_IDENTIFIER_AUTHORITY NtAuthority = SECURITY_NT_AUTHORITY; PSID AdministratorsGroup; b = AllocateAndInitializeSid( &NtAuthority, 2, SECURITY_BUILTIN_DOMAIN_RID, DOMAIN_ALIAS_RID_ADMINS, 0, 0, 0, 0, 0, 0, &AdministratorsGroup); if(b) { if (!CheckTokenMembership( NULL, AdministratorsGroup, &b)) { b = FALSE; } FreeSid(AdministratorsGroup); } return(b); }