USUÁRIO:      SENHA:        SALVAR LOGIN ?    Adicione o VBWEB na sua lista de favoritos   Fale conosco 

 

  Fórum

  Visual Basic
Voltar
Autor Assunto:  Desligar ou reiniciar o Win2000
Mateus 3M
DIVINOPOLIS
MG - BRASIL
ENUNCIADA !
Postada em 20/09/2004 14:14 hs            
e ai galera!?!
todo mundo maluco né! so de mexer com vb, + td bem.
alguém sabem como coloco o pc com win 2000 pra reiniciar?
   
Poca
não registrado
ENUNCIADA !
Postada em 20/09/2004 14:30 hs   
'No Form
 
Private Type LUID
    UsedPart As Long
    IgnoredForNowHigh32BitPart As Long
End Type
Private Type TOKEN_PRIVILEGES
    PrivilegeCount As Long
    TheLuid As LUID
    Attributes As Long
End Type
Public Enum EWX_MODES
    EWX_SHUTDOWN As Long = 1
    EWX_REBOOT = 2
    EWX_FORCE As Long = 4
    EWX_POWEROFF As Long = 8
End Enum
Private Declare Function ExitWindowsEx Lib "user32" (ByVal dwOptions As Long, ByVal dwReserved As Long) As Long
Private Declare Function GetCurrentProcess Lib "kernel32" () As Long
Private Declare Function OpenProcessToken Lib "advapi32" (ByVal ProcessHandle As Long, ByVal DesiredAccess As Long, TokenHandle As Long) As Long
Private Declare Function LookupPrivilegeValue Lib "advapi32" Alias "LookupPrivilegeValueA" (ByVal lpSystemName As String, ByVal lpName As String, lpLuid As LUID) As Long
Private Declare Function AdjustTokenPrivileges Lib "advapi32" (ByVal TokenHandle As Long, ByVal DisableAllPrivileges As Long, NewState As TOKEN_PRIVILEGES, ByVal BufferLength As Long, PreviousState As TOKEN_PRIVILEGES, ReturnLength As Long) As Long
Private Sub ExitWin2k(ExitMode as EWX_MODES)
    Const TOKEN_ADJUST_PRIVILEGES = &H20
    Const TOKEN_QUERY = &H8
    Const SE_PRIVILEGE_ENABLED = &H2
    Dim hdlProcessHandle As Long
    Dim hdlTokenHandle As Long
    Dim tmpLuid As LUID
    Dim tkp As TOKEN_PRIVILEGES
    Dim tkpNewButIgnored As TOKEN_PRIVILEGES
    Dim lBufferNeeded As Long
    hdlProcessHandle = GetCurrentProcess()
    OpenProcessToken hdlProcessHandle, (TOKEN_ADJUST_PRIVILEGES Or TOKEN_QUERY), hdlTokenHandle
    LookupPrivilegeValue "", "SeShutdownPrivilege", tmpLuid
    tkp.PrivilegeCount = 1
    tkp.TheLuid = tmpLuid
    tkp.Attributes = SE_PRIVILEGE_ENABLED
    AdjustTokenPrivileges hdlTokenHandle, False, tkp, Len(tkpNewButIgnored), tkpNewButIgnored, lBufferNeeded
    ExitWindowsEx (ExitMode), &HFFFF
End Sub
' No Command Button
 ExitWindowsEx (EWX_REBOOT), &HFFFF
 
T+
   
Mateus 3M
DIVINOPOLIS
MG - BRASIL
ENUNCIADA !
Postada em 20/09/2004 14:48 hs            
Cara valeu mesmo +...
 
colei  as linhas e algumas deram pau:
Public Enum EWX_MODES
    "essa" EWX_SHUTDOWN As Long = 1
    EWX_REBOOT = 2
    "essa" EWX_FORCE As Long = 4
    "essa" EWX_POWEROFF As Long = 8
End Enum
"essa"= erro de sintaxe
   
Mateus 3M
DIVINOPOLIS
MG - BRASIL
ENUNCIADA !
Postada em 20/09/2004 14:58 hs            
cara tirei os as long e as linhas se acertaram + nao funcionou q ta acontecendo?
   
Página(s): 1/1    


Seu Nome:

Seu eMail:

ALTERAR PARA MODO HTML
Mensagem:

[:)] = 
[:P] = 
[:(] = 
[;)] = 

HTML DESLIGADO

     
 VOLTAR

  



CyberWEB Network Ltda.    © Copyright 2000-2024   -   Todos os direitos reservados.
Powered by HostingZone - A melhor hospedagem para seu site
Topo da página