Lo que hace es Obtener/Duplicar los derechos de inicio de sesión del usuario, pero esto no es necesario de hacer ya que en el ejemplo de la msdn no lo usan, ni indican que haya que hacerlo.
Aquí te dejo el código en VB6 retocado.
Option Explicit
Private Const TOKEN_DUPLICATE = &H2&
Private Const TOKEN_QUERY = &H8&
Private Const ERROR_NO_TOKEN = 1008
Private Const SECURITY_BUILTIN_DOMAIN_RID = &H20&
Private Const DOMAIN_ALIAS_RID_ADMINS = &H220&
Private Const SECURITY_NT_AUTHORITY = &H5&
Private Type SID_IDENTIFIER_AUTHORITY
Value(6) As Byte
End Type
Private Enum SECURITY_IMPERSONATION_LEVEL
SecurityAnonymous
SecurityIdentification
SecurityImpersonation
SecurityDelegation
End Enum
Private Declare Function AllocateAndInitializeSid Lib "advapi32" (ByRef pIdentifierAuthority As SID_IDENTIFIER_AUTHORITY, ByVal nSubAuthorityCount As Byte, ByVal nSubAuthority0 As Long, ByVal nSubAuthority1 As Long, ByVal nSubAuthority2 As Long, ByVal nSubAuthority3 As Long, ByVal nSubAuthority4 As Long, ByVal nSubAuthority5 As Long, ByVal nSubAuthority6 As Long, ByVal nSubAuthority7 As Long, ByRef lpPSid As Long) As Long
Private Declare Function CheckTokenMembership Lib "advapi32" (ByVal TokenHandle As Long, ByVal SidToCheck As Long, ByRef IsMember As Long) As Long
Private Declare Sub FreeSid Lib "advapi32.dll" (ByVal pSid As Long)
Private Sub form_load()
If IsInRoleAdmin Then
MsgBox "admin"
Else
MsgBox "NO"
End If
End Sub
Public Function IsInRoleAdmin() As Boolean
Dim NtAuthority As SID_IDENTIFIER_AUTHORITY
Dim AdminGroup As Long
Dim Success As Long
' Well-known SIDs
NtAuthority.Value(5) = SECURITY_NT_AUTHORITY
' allocates and initializes a security identifier (SID)
Success = AllocateAndInitializeSid(NtAuthority, 2, _
SECURITY_BUILTIN_DOMAIN_RID, DOMAIN_ALIAS_RID_ADMINS, 0, 0, 0, 0, 0, 0, AdminGroup)
If CheckTokenMembership(0, AdminGroup, Success) = 0 Then
Success = 0
End If
FreeSid AdminGroup
IsInRoleAdmin = Success
End Function