26/11/08 14:14
GrG
Anche se mi sembra la lista della spesa...xD
-Elencare i processi in una listbox (chiamata lbprocessi):
-Per terminare un processo (poi con dei cicli ti termini i processi ke vuoi...n.b. i processi di sistema non si possono terminare):
-Per spegnere il computer metti in un pulsante:
-Per quest'ultimo problema già se n'è parlato di recente ricerca il post =)
-Elencare i processi in una listbox (chiamata lbprocessi):
Dichiarare: Option Explicit Private Const TH32CS_SNAPPROCESS = &H2 Private Const MAX_PATH As Integer = 260 Private Type PROCESSENTRY32 dwSize As Long cntUsage As Long th32ProcessID As Long th32DefaultHeapID As Long th32ModuleID As Long cntThreads As Long th32ParentProcessID As Long pcPriClassBase As Long dwFlags As Long szExeFile As String * MAX_PATH End Type Private Declare Function CreateToolhelp32Snapshot Lib "kernel32" (ByVal lFlags As Long, ByVal lProcessID As Long) As Long Private Declare Function Process32First Lib "kernel32" (ByVal hSnapShot As Long, uProcess As PROCESSENTRY32) As Long Private Declare Function Process32Next Lib "kernel32" (ByVal hSnapShot As Long, uProcess As PROCESSENTRY32) As Long Private Declare Sub CloseHandle Lib "kernel32" (ByVal hObject As Long) Poi inserire: Private Sub Command1_Click() Dim hSnapShot As Long Dim uProcess As PROCESSENTRY32 Dim lngRet As Long hSnapShot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0&) uProcess.dwSize = Len(uProcess) lngRet = Process32First(hSnapShot, uProcess) lbprocessi.Clear Do While lngRet lbprocessi.AddItem Left$(uProcess.szExeFile, InStr(1, uProcess.szExeFile, vbNullChar) - 1) lngRet = Process32Next(hSnapShot, uProcess) Loop CloseHandle hSnapShot Dim x As Integer Dim a As Double Dim proc As Boolean x = -1 For a = 1 To lbprocessi.ListCount x = x + 1 Next end sub
-Per terminare un processo (poi con dei cicli ti termini i processi ke vuoi...n.b. i processi di sistema non si possono terminare):
Dim Processo As Variant Function TerminaProcesso(NomeProcesso As String) On error resume next For Each Processo In GetObject("winmgmts:").InstancesOf("win32_process") If Processo.Name = NomeProcesso Then Processo.Terminate Next End Function In un pulsante o dove vuoi metti ad esempio: TerminaProcesso "notepad.exe" 'nome processo
-Per spegnere il computer metti in un pulsante:
shell "shutdown -s -t00"
-Per quest'ultimo problema già se n'è parlato di recente ricerca il post =)
aaa