estoy trtando de hacer andar una funcion de apagado de pc pero por alguna razon no funciona, lo quiero hacer en vb6 , lo depure con msg box porque no se todavia como depurar con vb (empece hace unos dias XD) y necesito hacer andar esta funcion. se trta de reiniciar la pc cuando apreto un button
mi depuracion me dijo que el la ejecucion cae en el primer message que dice "UNO" y sale, pero por que si en c anda bien esto?
agradeceria que me solucionen el funcionamiento de esto chicos
Código:
Private Sub Command2_Click()
Dim MsgRet As Integer
MsgRet = MsgBox("Desea apagar su pc?", 36, MB_OK)
If MsgRet = 6 Then
Dim OsInfo As OSVERSIONINFO
OsInfo.dwOSVersionInfoSize = Len(OSVERSIONINFO)
If OsInfo.dwPlatformId = VER_PLATFORM_WIN32_NT Then
Dim hToken As Long
Dim tkp As TOKEN_PRIVILEGES
If Not OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES Or TOKEN_QUERY, VarPtr(hToken)) Then
Call MsgBox("UNO", 36, MB_OK)
End
End If
'Call MsgBox("DOS", 36, MB_OK)
Dim tmpLuid As LUID
Call LookupPrivilegeValue(0, SE_SHUTDOWN_NAME, tmpLuid)
tkp.Privileges(0).vLuid = tmpLuid
tkp.PrivilegeCount = 1
tkp.Privileges(0).Attributes = SE_PRIVILEGE_ENABLED
Call AdjustTokenPrivileges(hToken, 0, tkp, 0, ByVal 0&, ByVal 0&)
If Not GetLastError() = ERROR_SUCCESS Then
End
End If
'Call MsgBox("TRES", 36, MB_OK)
If ExitWindowsEx(EWX_POWEROFF Or EWX_FORCE, 0) = 0 Then
End If
End If
End
End If
End Sub