Visualizzazione dei risultati da 1 a 4 su 4

Discussione: [VB.NET] Spegnere PC

  1. #1

    vb.net spegnere pc

    Ciao ragazzi,
    qualcuno di voi mi sa dire come si spegne un pc tramite codice vb.net?

    grazie per l'aiuto...


  2. #2

  3. #3
    Utente di HTML.it L'avatar di mvent
    Registrato dal
    Jun 2002
    Messaggi
    230
    con questa "API" hai provato ?!
    (col vb6 funziona)

    Public Declare Function ExitWindowsEx Lib "user32" Alias "ExitWindowsEx" (ByVal uFlags As Long, ByVal dwReserved As Long) As Long


    ;-)
    ciao
    mauro v.

  4. #4
    Utente di HTML.it
    Registrato dal
    Jul 2001
    Messaggi
    798
    codice:
    Dim ms As System.Management.ManagementScope = New System.Management.ManagementScope("\\LocalHost\root\cimv2")
            Dim mo As System.Management.ManagementObject
    
            ms.Options.EnablePrivileges = True
    
            ms.Options.Password = ""
            ms.Options.Username = ""
    
            Dim oq As System.Management.ObjectQuery = New System.Management.ObjectQuery("SELECT * FROM Win32_OperatingSystem")
            Dim query1 As System.Management.ManagementObjectSearcher = New System.Management.ManagementObjectSearcher(ms, oq)
            Dim queryCollection1 As System.Management.ManagementObjectCollection = query1.Get()
    
            For Each mo In queryCollection1
                Dim ss As String() = {"2", "0"} ' Shutdown
                mo.InvokeMethod("Win32Shutdown", ss)
            Next
    lascio a te provare.

    Ans.

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.