Título: apagado de pc en vb Publicado por: neo_from_cs_matrix en 7 Marzo 2012, 05:33 am 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 Título: Re: apagado de pc en vb Publicado por: BlackZeroX (Astaroth) en 7 Marzo 2012, 05:38 am http://msdn.microsoft.com/en-us/library/windows/desktop/aa379295(v=vs.85).aspx
Citar Return value If the function succeeds, the return value is nonzero. If the function fails, the return value is zero. To get extended error information, call GetLastError. Remarks Close the access token handle returned through the TokenHandle parameter by calling CloseHandle. Dulces Lunas!ˇ. |