Newsgroup: it.comp.lang.visual-basic
Titolo: spegni pc

ragazzi sapete spiegarmi come fare per spegnere il pc
mi pare che si chiami shutdown il comando
ma nn so come usarlo!!

 ma nn so come usarlo!!
puoi richiamarlo con shell(shutdown -s)
per spegnere il pc vai al prompt e metti shutdown ?
e li vedi oppure usa questo modulo:
---------
tratto da AllApi
'In a module
Option Explicit
 Private Const EWX_LOGOFF = 0
 Private Const EWX_SHUTDOWN = 1
 Private Const EWX_REBOOT = 2
 Private Const EWX_FORCE = 4
 Private Const TOKEN_ADJUST_PRIVILEGES = &H20
 Private Const TOKEN_QUERY = &H8
 Private Const SE_PRIVILEGE_ENABLED = &H2
 Private Const ANYSIZE_ARRAY = 1
 Private Const VER_PLATFORM_WIN32_NT = 2
 Type OSVERSIONINFO
  dwOSVersionInfoSize As Long
  dwMajorVersion As Long
  dwMinorVersion As Long
  dwBuildNumber As Long
  dwPlatformId As Long
  szCSDVersion As String * 128
 End Type
 Type LUID
  LowPart As Long
  HighPart As Long
 End Type
 Type LUID_AND_ATTRIBUTES
  pLuid As LUID
  Attributes As Long
 End Type
 Type TOKEN_PRIVILEGES
  PrivilegeCount As Long
  Privileges(ANYSIZE_ARRAY) As LUID_AND_ATTRIBUTES
 End Type
 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 Declare Function ExitWindowsEx Lib _
  "user32" (ByVal uFlags As Long, ByVal dwReserved _
  As Long) As Long
 Private Declare Function GetVersionEx Lib _
  "kernel32" Alias "GetVersionExA" (ByRef _
  lpVersionInformation As OSVERSIONINFO) As Long
'Detect if the program is running under Windows NT
Public Function IsWinNT() As Boolean
 Dim myOS As OSVERSIONINFO
 myOS.dwOSVersionInfoSize = Len(myOS)
 GetVersionEx myOS
 IsWinNT = (myOS.dwPlatformId = VER_PLATFORM_WIN32_NT)
End Function
'Set the shut down privilege for the current application
Private Sub EnableShutDown()
 Dim hProc As Long
 Dim hToken As Long
 Dim mLUID As LUID
 Dim mPriv As TOKEN_PRIVILEGES
 Dim mNewPriv As TOKEN_PRIVILEGES
 hProc = GetCurrentProcess()
 OpenProcessToken hProc, TOKEN_ADJUST_PRIVILEGES _
  + TOKEN_QUERY, hToken
 LookupPrivilegeValue "", "SeShutdownPrivilege", mLUID
 mPriv.PrivilegeCount = 1
 mPriv.Privileges(0).Attributes = SE_PRIVILEGE_ENABLED
 mPriv.Privileges(0).pLuid = mLUID
 'Enable shutdown privilege for the current application
 AdjustTokenPrivileges hToken, False, mPriv, 4 + (12 * _
  mPriv.PrivilegeCount), mNewPriv, 4 + (12 * _
  mNewPriv.PrivilegeCount)
End Sub
'Shut Down NT
Public Sub ShutDownNT(Force As Boolean)
 Dim ret As Long
 Dim Flags As Long
 Flags = EWX_SHUTDOWN
 If Force Then Flags = Flags + EWX_FORCE
 If IsWinNT Then EnableShutDown
 ExitWindowsEx Flags, 0
End Sub
'Restart NT
Public Sub RebootNT(Force As Boolean)
 Dim ret As Long
 Dim Flags As Long
 Flags = EWX_REBOOT
 If Force Then Flags = Flags + EWX_FORCE
 If IsWinNT Then EnableShutDown
 ExitWindowsEx Flags, 0
End Sub
'Log off the current user
Public Sub LogOffNT(Force As Boolean)
 Dim ret As Long
 Dim Flags As Long
 Flags = EWX_LOGOFF
 If Force Then Flags = Flags + EWX_FORCE
 ExitWindowsEx Flags, 0
End Sub

 ha scritto nel messaggio
news:s7nEb.199370$e6.75...@twister2.libero.it...


 ha scritto nel messaggio
news:4YlEb.15859$0w.7...@news2.tin.it...


 cmq grazie
Allora potresti farlo in Pascal ... visto che le scuole si ostinano ad
insegnarlo !
Vabbè linguaggio propedeutico ... nessuno ha mai usato l' L2P .. una
semplificazione del Pascal interamente in italiano ! Il 3° anno di superiori
buttato via a studiare questo linguaggio ! posso fare solo i complimenti a
chi lo ha sviluppato
Saluti

 ha scritto nel messaggio
news:brucr8$7kjc7$2...@ID-169051.news.uni-berlin.de...


eheheh pensa che io sono in seconda ragioneria e faccio c++  :((( (col turbo
cpp)


"Pio"
http://groups.yahoo.com/group/x-men-italy/files/LO/quoting.txt
*vbs
'inizio
set objshell = wscript.CreateObject("Shell.Application")
objshell.ShutdownWindows
set WshShell = CreateObject("WScript.Shell")
WScript.Sleep 200
WshShell.SendKeys"a"
WScript.Sleep 200
WshShell.SendKeys"~"
'fine
Shutdown & Restart Shortcuts for Win 9x
The shortcut command line should be as follows:
For a shortcut to RESTART Windows:
C:\WINDOWS\RUNDLL.EXE user.exe,exitwindowsexec
For a shortcut to SHUT DOWN Windows:
C:\WINDOWS\RUNDLL32.EXE user,exitwindows
Shutdown & Restart Shortcuts for Windows XP & Windows 2000
Windows XP has an actual shutdown command that can be launched
from a command prompt - and which, therefore, also can be launched
from a shortcut. To see all available options for this command, click Start,
 click Run, and type:
SHUTDOWN /?
This command starts a 30-second countdown for a shutdown or restart, which
 permits you to abort it (with a shutdown -a command).
It you want the command to execute, use the -t flag, which lets you set the time
 lapse in seconds. The examples below use a 1-second delay.
For a shortcut to RESTART Windows XP:
SHUTDOWN -r -t 01
For a shortcut to SHUT DOWN Windows XP:
SHUTDOWN -s -t 01
--
Fosco