Arrrrgh - Problems using OpenProcessToken

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jg007
    Contributor
    • Mar 2008
    • 283

    Arrrrgh - Problems using OpenProcessToken

    I have been trying to convert some C# code to VB but am getting stuck i've Tried everyting and spent ages on google but keep on getting Error 998 which I checked and is ERROR_NOACCESS when I check the last dll error although the c# code works fine, can anybody help please

    Code:
    Public Declare Function OpenProcessToken Lib "advapi32.dll" _ (ByVal ProcessHandle As Long, ByVal DesiredAccess As Long, _ ByVal TokenHandle As Long) As Long
    
        Private Const TOKEN_ADJUST_PRIVLEGES = &H20
        Private Const TOKEN_QUERY = &H8
        Private Const SE_PRIVILEGE_ENABLED = &H2
    
    MyToken = 0
    Retval = OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVLEGES Or TOKEN_QUERY, MyToken)
    
       MsgBox("OpenProcess: " & Err.LastDllError)
Working...