Ermitteln, ob der angemeldete Benutzer Administrator ist

Ermitteln, ob der angemeldete Benutzer Administrator ist: OpenSCManager, GENERIC_EXECUTE
Private Type OSVERSIONINFO
dwOSVersionInfoSize As Long
dwMajorVersion As Long
dwMinorVersion As Long
dwBuildNumber As Long
dwPlatformId As Long
szCSDVersion As String * 128
End Type
Private Const WIN_32_WINDOWS = 1
Private Const WIN_32_NT = 2
Private Const GENERIC_EXECUTE = &H20000000
Private Const GENERIC_READ = &H80000000
Private Const GENERIC_WRITE = &H40000000
Private Declare Function OpenSCManager Lib "advapi32.dll" _
Alias "OpenSCManagerA" (ByVal lpMachineName As String, _
ByVal lpDatabaseName As String, ByVal dwDesiredAccess As Long) As Long
Private Declare Function CloseServiceHandle _
Lib "advapi32.dll" (ByVal hSCObject As Long) As Long
Private Declare Function GetVersionEx Lib "kernel32" _
Alias "GetVersionExA" (lpVersionInformation As OSVERSIONINFO) As Long
Function IsAdmin() As Boolean
Dim hSC As Long
Dim tOSV As OSVERSIONINFO
Dim lOS As Long
Plattform ermitteln
tOSV.dwOSVersionInfoSize = Len(tOSV)
Call GetVersionEx(tOSV)
lOS = tOSV.dwPlatformId
If lOS = WIN_32_NT Then
hSC = OpenSCManager(vbNullString, vbNullString, _
GENERIC_READ Or GENERIC_WRITE Or GENERIC_EXECUTE)
If hSC = 0 Then
IsAdmin = False
Else
IsAdmin = True
End If
CloseServiceHandle (hSC)
Else
IsAdmin = True
End If
End Function
Sub Form_Load()
MsgBox IsAdmin
End Sub

Mehr Tipps: Desktop-Hintergrundbild ändern

Sponsoren und Investoren

Sponsoren und Investoren sind jederzeit herzlich willkommen!
Wenn Sie die Information(en) auf dieser Seite interessant fanden, freuen wir uns über eine kleine Spende. Empfehlen Sie uns bitte auch in Ihren Netzwerken (z. B. Twitter, Facebook oder Google+). Herzlichen Dank!

Nach oben Sitemap
Impressum & Kontakt