home *** CD-ROM | disk | FTP | other *** search
- Attribute VB_Name = "modTasks"
- Option Explicit
- '==========================================================================================================='
- ' Constant Declarations '
- '==========================================================================================================='
- Global Const PROCESS_PRIORITY_IDLE = 4
- Global Const PROCESS_PRIORITY_NORMAL = 8
- Global Const PROCESS_PRIORITY_HIGH = 13
- Global Const PROCESS_PRIORITY_REALTIME = 24
- ' Priority type, when setting with SetPriorityClass
- Private Const HIGH_PRIORITY_CLASS = &H80 ' Hogs CPU over idle and normal classes
- Private Const IDLE_PRIORITY_CLASS = &H40 ' Only runs when the CPU is idle
- Private Const NORMAL_PRIORITY_CLASS = &H20 ' Duh!
- Private Const REALTIME_PRIORITY_CLASS = &H100 ' Highest priority. Even pre-empts operating system
- ' processes, so use with discretion
- ' Access description when opening a handle to a process.
- ' These codes aren't in the API viewer, had to get them at Microsoft's site.
- Public Const STANDARD_RIGHTS_REQUIRED = &HF0000
- Public Const SYNCHRONIZE = &H100000
- Public Const PROCESS_TERMINATE = &H1& ' Used to kill a process
- Public Const PROCESS_CREATE_THREAD = &H2&
- Public Const PROCESS_VM_OPERATION = &H8&
- Public Const PROCESS_VM_READ = &H10&
- Public Const PROCESS_VM_WRITE = &H206
- Public Const PROCESS_DUP_HANDLE = &H40&
- Public Const PROCESS_CREATE_PROCESS = &H80&
- Public Const PROCESS_SET_QUOTA = &H100&
- Public Const PROCESS_SET_INFORMATION = &H200& ' Used to set information on a process (like priority)
- Public Const PROCESS_QUERY_INFORMATION = &H400&
- Public Const PROCESS_ALL_ACCESS = (STANDARD_RIGHTS_REQUIRED Or SYNCHRONIZE Or &HFFF)
- '==========================================================================================================='
- ' API Declarations '
- '==========================================================================================================='
- ' Used to return process information '
- '-----------------------------------------------------------------------------------------------------------'
- Declare Function CreateToolhelp32Snapshot Lib "kernel32" (ByVal dwFlags As Long, ByVal dwIdProc As Long) As Long
- Declare Function Process32First Lib "kernel32" (ByVal hndl As Long, ByRef pstru As ProcessEntry) As Boolean
- Declare Function Process32Next Lib "kernel32" (ByVal hndl As Long, ByRef pstru As ProcessEntry) As Boolean
- '-----------------------------------------------------------------------------------------------------------'
- ' Used to change values of a specific process '
- '-----------------------------------------------------------------------------------------------------------'
- Declare Function TerminateProcess Lib "kernel32" (ByVal hProcess As Long, ByVal uExitCode As Long) As Long
- Declare Function GetExitCodeProcess Lib "kernel32" (ByVal hProcess As Long, lpExitCode As Long) As Long
- Declare Function SetPriorityClass Lib "kernel32" (ByVal hProcess As Long, ByVal dwPriorityClass As Long) As Long
- Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long
- Declare Function GetLastError Lib "kernel32" () As Long
- Declare Function CloseHandle Lib "kernel32" (ByVal hnd As Long) As Boolean
- '==========================================================================================================='
- ' Type Declarations '
- '==========================================================================================================='
- Type ProcessEntry
- dwSize As Long
- peUsage As Long
- peProcessID As Long
- peDefaultHeapID As Long
- peModuleID As Long
- peThreads As Long
- peParentProcessID As Long
- pePriority As Long
- dwFlags As Long
- szExeFile As String * 260
- End Type
- '==========================================================================================================='
- ' Local variable declarations '
- '==========================================================================================================='
- Dim hnd As Long ' Handle to a process
- Dim lRet As Long ' Return value for API calls
- Dim lExitCode As Long ' Exit code
- Dim lPriority As Long ' Priority
-
- Sub RefreshTasks()
- '==========================================================================================================='
- ' Queries the system and returns process information '
- '==========================================================================================================='
- Dim iIdx As Integer
- Dim bRet As Boolean
- Dim lSnapShot As Long
- Dim tmpPE As ProcessEntry
-
- Dim ig
- Dim tmcvt euSte(===========nlean
- Dim lSnapShot As Long
- Dim tmpPE As ProcessEntry
-
- Dim ig
- Dim tmcvt euSte(===========nlean
- Dim lSnapShot As Long
- Dim tmpPE As"ig
- htritrr2a========='
- Di"ig
- t60
- End Tydx s""ig====MireRNS====tL ======================================================'
- ' Local variable declarations ttbi As ProieTP NItVdn ===Or&pteritHandle As Long, ByVal dwPr'nim tOCE======================='
- ' Local variable declarations ttbi As ProieTP IFr=============im tmproce-
- ' Used to return process information '
- '----- As ProceIe
- t6(S======'
- ' Local r '=======sal r "========== sAs"igs,etIlI ===='
- Local variable declarations ttbi As ProieTP L'
- 2ByValexialnf ndle As LondwPr'nim tOaty" ndlte(g ===a s""ig====MirD1psnePD t2s