winapi - CheckTokenMembership in VB6 -
I'm having trouble converting this C ++ code to VB6 code. I have searched the net and I have some PInvoke.net is only in reference to VB.NET code. Here is the code from MSDN:
BOOL IsUserAdmin (zero) / * ++ Regular details: This regular return is correct, then the processor of the caller is a member of the local group. The caller is unlikely to impersonate someone and it is likely to be able to open its own process and process token. Logic: No return value: Right - the caller has the administrator local group. Wrong - The caller does not have administrator local group. - * / {BOOL b; SID_IDENTIFIER_AUTHORITY NtAuthority = SECURITY_NT_AUTHORITY; Psid administrator group; B = AllocateAndInitializeSid (& amp; NTAUTHORITY, 2, SECURITY_BUILTIN_DOMAIN_RID, DOMAIN_ALIAS_RID_ADMINS, 0, 0, 0, 0, 0, 0, & amp; AdministratorsGroup); If (B) {if (check! TokenMemberShip (NULL, Administrator Group, & amp; B)) {b = FALSE; } Freeside (Admin Group); } Return (B); }
It would be great if someone can help to convert it to VB6 code.
Thank you! In
Edit: I basically have to use the function that was going on, but say MSDN: ". This function CheckTokenMembership a cover is not that direct contact with the function call IsUserAnAdmin for Instead the administrator is recommended to set the group status. " Of
The
Options Clear Private Const SECURITY_BUILTIN_DOMAIN_RID Long = & amp Try As, H20 Personal Connection By DOMAIN_ALIAS_RID_ADMINS = & amp; H220 as any, ByVal nSubAuthorityCount byte as a personal promotional event AllocateAndInitializeSid Lib "advapi32.dll" (pIdentifierAuthority, ByVal nSubAuthority0 long as long, ByVal nSubAuthority1, Byval nSubAuthority2 long, the Byval nSubAuthority3 tall, Byval nSubAuthority4 long, Byval long as nSubAuthority5, Byval as nSubAuthority6 as long, by Val Ansyuebiothrititi 7, long, Elpeepisaid live personal publicity as long) loan sub FreeSid Lib "advapi32 form. Dll "(ByVal pSid) Private Event Su function CheckTokenMembership Lib "advapi32.dll" (ByVal hToken Long, ByVal pSidToCheck Long, pbIsMember as long as) long personal type SID_IDENTIFIER_AUTHORITY value as (0 to 5) bytes and type Personal function in pvIsAdmin () Boolean dim UID as SID_IDENTIFIER_AUTHORITY Dim pSidAdmins long as long dimension length uAuthNt.Value (5) = 5 If AllocateAndInitializeSid (uAuthNt, 2, SECURITY_BUILTIN_DOMAIN_RID, DOMAIN_ALIAS_RID_ADMINS, 0, 0, 0, 0, 0, 0, psidadmin)
Comments
Post a Comment