?
Solved

how to get cpu time and usage in vb6 for a specific program.

Posted on 2006-05-10
9
Medium Priority
?
1,154 Views
Last Modified: 2007-12-19
I need to watch an application and see when it is no longer using any cpu so I can kill it.  the program doesn;'t end when it is complete it just puts up a msg box with an OK button and no window title.  We dont want the user to see it so wee need to wait a while see if the app is doing anything then kill it.

Any ideas

remember no title bar..its empty just some text on the form and an ok button

thanks

0
Comment
Question by:ocsscott
6 Comments
 

Author Comment

by:ocsscott
ID: 16652390
or is there a sure fire way to send a key stroke to a window with no title?

I need to scan until I see a window with "uninstall sucessfull" and an OK button, I know the name of the exe so I can get a process ID,

so Can I scan somehow for this window and send the OK with no title?

thanks
0
 

Author Comment

by:ocsscott
ID: 16657585
navstar, please note above I need the processor usage for a task or process example calc.exe not the whole cpu or windows.

I NEED TO KNOW WHEN A TASK IS DONE PROCESSING BUT NOT CLOSED DUE TO NEED FOR USER INPUT ON A OK BUTTON.

THANKS
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 28

Expert Comment

by:Ark
ID: 16679939
Hi
Here is my VB ProcessList using HKEY_DYN_DATA hidden registry key:

'========================================
'                   MODULES (5 TOTAL)
' Just add new modules to VB project and
' copy/paste source into it.
'========================================

'================mMisc.bas================
'miscelaneous functions to convert values
'into readable format, plus common API
'=========================================
Option Explicit

Public Type LARGE_INTEGER
    LowPart As Long
    HighPart As Long
End Type

Public Type SYSTEMTIME
   wYear As Integer
   wMonth As Integer
   wDayOfWeek As Integer
   wDay As Integer
   wHour As Integer
   wMinute As Integer
   wSecond As Integer
   wMilliseconds As Integer
End Type

Public Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (Destination As Any, Source As Any, ByVal Length As Long)
Public Declare Function StrFormatByteSize Lib "Shlwapi" Alias "StrFormatByteSizeW" (ByVal dw As Currency, ByVal pszBuf As Long, ByVal cchBuf As Long) As Long
Public Declare Function FileTimeToSystemTime Lib "kernel32" (lpFileTime As LARGE_INTEGER, lpSystemTime As SYSTEMTIME) As Long
Public Declare Function FileTimeToLocalFileTime Lib "kernel32" (lpFileTime As LARGE_INTEGER, lpLocalFileTime As LARGE_INTEGER) As Long
Private Declare Function lstrlenW Lib "kernel32" (ByVal lpString As Long) As Long

'Truncate ANSI string up to Null Char
Public Function TrimNull(startstr As String) As String
   Dim pos As Integer
   pos = InStr(startstr, Chr$(0))
   If pos Then
      TrimNull = Left$(startstr, pos - 1)
      Exit Function
   End If
   TrimNull = startstr
End Function

'Format bytes into readable format (KB, MB or GB using national settings)
Public Function FormatByteSize(ByVal Bytes As Currency) As String
   Dim strBuff As String * 256
   Dim nRet As Long
   nRet = StrFormatByteSize(Bytes / 10000, StrPtr(strBuff), 256)
   If nRet Then FormatByteSize = Ptr2StrU(nRet)
End Function

'Add leading zeroes
Public Function ZeroPad(ByVal s As String, n As Long) As String
    ZeroPad = Right(String(n, "0") & s, n)
End Function

'Read unicode string from memory pointer
Public Function Ptr2StrU(ByVal pAddr As Long, Optional dwSize As Long) As String
   If pAddr = 0 Then Exit Function
   If dwSize = 0 Then dwSize = lstrlenW(pAddr)
   Ptr2StrU = Space$(dwSize)
   CopyMemory ByVal StrPtr(Ptr2StrU), ByVal pAddr, dwSize * 2
End Function

'Convert FileTime structutre to VB Date_Time format
Public Function FileTimeToVBTime(ByVal value As Variant) As Date
    Dim st As SYSTEMTIME
    Dim ft As LARGE_INTEGER
    Dim curTemp As Currency
    Select Case TypeName(value)
           Case vbCurrency
               curTemp = CCur(value)
           Case Else
               curTemp = CCur(value / 10000)
    End Select
    CopyMemory ft, curTemp, 8
    FileTimeToLocalFileTime ft, ft
    Call FileTimeToSystemTime(ft, st)
    FileTimeToVBTime = TimeSerial(st.wHour, st.wMinute, st.wSecond)
End Function

'================mPerf.bas================
'initialize variable counters and read
'performance data into bytes array
'=========================================

Public Type COUNTERS_ID
   Process                      As String
   Processor_Time               As String
   User_Time                    As String
   Privileged_Time              As String
   Virtual_Bytes_Peak           As String
   Virtual_Bytes                As String
   Page_Faults_per_sec          As String
   Working_Set_Peak             As String
   Working_Set                  As String
   Page_File_Bytes_Peak         As String
   Page_File_Bytes              As String
   Private_Bytes                As String
   Thread_Count                 As String
   Priority_Base                As String
   Elapsed_Time                 As String
   ID_Process                   As String
   Creating_Process_ID          As String
   Pool_Paged_Bytes             As String
   Pool_Nonpaged_Bytes          As String
   Handle_Count                 As String
   IO_Read_Operations_per_sec   As String
   IO_Write_Operations_per_sec  As String
   IO_Data_Operations_per_sec   As String
   IO_Other_Operations_per_sec  As String
   IO_Read_Bytes_per_sec        As String
   IO_Write_Bytes_per_sec       As String
   IO_Data_Bytes_per_sec        As String
   IO_Other_Bytes_per_sec       As String
End Type

Public counters As COUNTERS_ID
Dim bInit As Boolean
Public g_colCounters As Collection

'Initialize counters (get counter's indexes from their names)
'Perform only once when program starts.
Public Function InitCounters(Optional bForce As Boolean) As Boolean
   If bForce Then bInit = False
   If bInit Then
      InitCounters = True
      Exit Function
   End If
   Dim hKey As Long, lType As Long, dwSize As Long, ret As Long, i As Long
   Dim abData() As Byte
   Dim s As String
   Dim sVal() As String
   
   ret = RegOpenKeyEx(HKEY_LOCAL_MACHINE, PerfLibKey, 0, KEY_READ, hKey)
   If hKey = 0 Then Exit Function
   
   RegQueryValueEx hKey, "Counter", 0, lType, 0, dwSize
   If dwSize Then
      ReDim abData(dwSize - 1)
      RegQueryValueEx hKey, "Counter", 0, lType, abData(0), dwSize
      s = StrConv(abData, vbUnicode)
      sVal = Split(s, Chr(0))
      Set g_colCounters = Nothing
      Set g_colCounters = New Collection
      For i = 2 To UBound(sVal) - 2 Step 2
          g_colCounters.Add sVal(i + 1), sVal(i)
          Select Case Trim(sVal(i + 1))
             Case "Process":                 counters.Process = sVal(i)
             Case "% Processor Time":        counters.Processor_Time = sVal(i)
             Case "% User Time":             counters.User_Time = sVal(i)
             Case "% Privileged Time":       counters.Privileged_Time = sVal(i)
             Case "Virtual Bytes Peak":      counters.Virtual_Bytes_Peak = sVal(i)
             Case "Virtual Bytes":           counters.Virtual_Bytes_Peak = sVal(i)
             Case "Page Faults / sec":       counters.Page_Faults_per_sec = sVal(i)
             Case "Working Set Peak":        counters.Working_Set_Peak = sVal(i)
             Case "Working Set":             counters.Working_Set = sVal(i)
             Case "Page File Bytes Peak":    counters.Page_File_Bytes_Peak = sVal(i)
             Case "Page File Bytes":         counters.Page_File_Bytes = sVal(i)
             Case "Private Bytes":           counters.Private_Bytes = sVal(i)
             Case "Thread Count":            counters.Thread_Count = sVal(i)
             Case "Priority Base":           counters.Priority_Base = sVal(i)
             Case "Elapsed Time":            counters.Elapsed_Time = sVal(i)
             Case "ID Process":              counters.ID_Process = sVal(i)
             Case "Creating Process ID":     counters.Creating_Process_ID = sVal(i)
             Case "Pool Paged Bytes":        counters.Pool_Paged_Bytes = sVal(i)
             Case "Pool Nonpaged Bytes":     counters.Pool_Nonpaged_Bytes = sVal(i)
             Case "Handle Count":            counters.Handle_Count = sVal(i)
             Case "IO Read Operations/sec":  counters.IO_Read_Operations_per_sec = sVal(i)
             Case "IO Write Operations/sec": counters.IO_Write_Operations_per_sec = sVal(i)
             Case "IO Data Operations/sec":  counters.IO_Data_Operations_per_sec = sVal(i)
             Case "IO Other Operations/sec": counters.IO_Other_Operations_per_sec = sVal(i)
             Case "IO Read Bytes/sec":       counters.IO_Read_Bytes_per_sec = sVal(i)
             Case "IO Write Bytes/sec":      counters.IO_Write_Bytes_per_sec = sVal(i)
             Case "IO Data Bytes/sec":       counters.IO_Data_Bytes_per_sec = sVal(i)
             Case "IO Other Bytes/sec":      counters.IO_Other_Bytes_per_sec = sVal(i)
             Case Else
          End Select
      Next i
   End If
   RegCloseKey hKey
End Function

'Get indexed counter's value
Public Function GetPerfData(ByVal idx As Long) As Byte()
   
   Dim hKey As Long, lType As Long, dwSize As Long, ret As Long
   Dim abData() As Byte
   ReDim abData(0)
   lType = REG_BINARY
   
   Do While RegQueryValueEx(HKEY_PERFORMANCE_DATA, CStr(idx), 0, lType, abData(0), dwSize) = ERROR_MORE_DATA
      dwSize = dwSize + 100000
      ReDim abData(dwSize - 1)
      If dwSize > 1000000 Then Exit Do
   Loop
   Call RegCloseKey(HKEY_PERFORMANCE_DATA)
   GetPerfData = abData
   Erase abData
End Function

'================mPerfDef.bas================
'Performance counters constants
'and structures definition
'=========================================
Option Explicit

Public Const PERF_DATA_VERSION = 1
Public Const PERF_DATA_REVISION = 1

Public Type PERF_DATA_BLOCK
'    Signature(7) As Byte '"PERF" in unicode
    Signature As String * 8
    LittleEndian As Long
    Version As Long
    Revision As Long
    TotalByteLength As Long
    HeaderLength As Long
    NumObjectTypes As Long
    DefaultObject As Long
    SysTime As SYSTEMTIME
    PerfTime As LARGE_INTEGER
    PerfFreq As LARGE_INTEGER
    PerTime100nSec As LARGE_INTEGER
    SystemNameLength As Long
    SystemNameOffset As Long
End Type

Public Type PERF_OBJECT_TYPE
    TotalByteLength As Long
    DefinitionLength As Long
    HeaderLength As Long
    ObjectNameTitleIndex As Long
    lpwObjectNameTitle As Long 'String
    ObjectHelpTitleIndex As Long
    lpwObjectHelpTitle As Long 'String
    DetailLevel As Long
    NumCounters As Long
    DefaultCounter As Long
    NumInstances As Long
    CodePage As Long
    PerfTime As LARGE_INTEGER
    PerfFreq As LARGE_INTEGER
End Type

Public Type PERF_COUNTER_DEFINITION
    ByteLength As Long
    CounterNameTitleIndex As Long
    lpwCounterNameTitle As Long 'String
    CounterHelpTitleIndex As Long
    lpwCounterHelpTitle As Long 'String
    DefaultScale As Long
    DetailLevel As Long
    CounterType As Long
    CounterSize As Long
    CounterOffset As Long
End Type

Public Type PERF_INSTANCE_DEFINITION
    ByteLength As Long
    ParentObjectTitleIndex As Long
    ParentObjectInstance As Long
    UniqueID As Long
    NameOffset As Long
    NameLength As Long
End Type

Public Type PERF_COUNTER_BLOCK
    ByteLength As Long
End Type

Public Const PERF_NO_INSTANCES = -1  '  no instances

' The counter type is the "or" of the following values as described below
'
' select one of the following to indicate the counter's data size
Public Const PERF_SIZE_DWORD = &H0
Public Const PERF_SIZE_LARGE = &H100
Public Const PERF_SIZE_ZERO = &H200            '  for Zero Length fields
Public Const PERF_SIZE_VARIABLE_LEN = &H300    '  length is in CounterLength field of Counter Definition struct

' select one of the following values to indicate the counter field usage
Public Const PERF_TYPE_NUMBER = &H0            '  a number (not a counter)
Public Const PERF_TYPE_COUNTER = &H400         '  an increasing numeric value
Public Const PERF_TYPE_TEXT = &H800            '  a text field
Public Const PERF_TYPE_ZERO = &HC00            '  displays a zero

' If the PERF_TYPE_NUMBER field was selected, then select one of the
' following to describe the Number
Public Const PERF_NUMBER_HEX = &H0             '  display as HEX value
Public Const PERF_NUMBER_DECIMAL = &H10000     '  display as a decimal integer
Public Const PERF_NUMBER_DEC_1000 = &H20000    '  display as a decimal/1000
'
' If the PERF_TYPE_COUNTER value was selected then select one of the
' following to indicate the type of counter
Public Const PERF_COUNTER_VALUE = &H0          '  display counter value
Public Const PERF_COUNTER_RATE = &H10000       '  divide ctr / delta time
Public Const PERF_COUNTER_FRACTION = &H20000   '  divide ctr / base
Public Const PERF_COUNTER_BASE = &H30000       '  base value used in fractions
Public Const PERF_COUNTER_ELAPSED = &H40000    '  subtract counter from current time
Public Const PERF_COUNTER_QUEUELEN = &H50000   '  Use Queuelen processing func.
Public Const PERF_COUNTER_HISTOGRAM = &H60000  '  Counter begins or ends a histogram

' If the PERF_TYPE_TEXT value was selected, then select one of the
' following to indicate the type of TEXT data.
Public Const PERF_TEXT_UNICODE = &H0           '  type of text in text field
Public Const PERF_TEXT_ASCII = &H10000         '  ASCII using the CodePage field

' Timer SubTypes
Public Const PERF_TIMER_TICK = &H0             '  use system perf. freq for base
Public Const PERF_TIMER_100NS = &H100000       '  use 100 NS timer time base units
Public Const PERF_OBJECT_TIMER = &H200000      '  use the object timer freq

' Any types that have calculations performed can use one or more of
' the following calculation modification flags listed here
Public Const PERF_DELTA_COUNTER = &H400000     '  compute difference first
Public Const PERF_DELTA_BASE = &H800000        '  compute base diff as well
Public Const PERF_INVERSE_COUNTER = &H1000000  '  show as 1.00-value (assumes:
Public Const PERF_MULTI_COUNTER = &H2000000    '  sum of multiple instances

' Select one of the following values to indicate the display suffix (if any)
Public Const PERF_DISPLAY_NO_SUFFIX = &H0      '  no suffix
Public Const PERF_DISPLAY_PER_SEC = &H10000000 '  "/sec"
Public Const PERF_DISPLAY_PERCENT = &H20000000 '  "%"
Public Const PERF_DISPLAY_SECONDS = &H30000000 '  "secs"
Public Const PERF_DISPLAY_NOSHOW = &H40000000  '  value is not displayed

' Predefined counter types

' 32-bit Counter.  Divide delta by delta time.  Display suffix: "/sec"
Public Const PERF_COUNTER_COUNTER = (PERF_SIZE_DWORD Or PERF_TYPE_COUNTER Or PERF_COUNTER_RATE Or PERF_TIMER_TICK Or PERF_DELTA_COUNTER Or PERF_DISPLAY_PER_SEC)

' 64-bit Timer.  Divide delta by delta time.  Display suffix: "%"
Public Const PERF_COUNTER_TIMER = (PERF_SIZE_LARGE Or PERF_TYPE_COUNTER Or PERF_COUNTER_RATE Or PERF_TIMER_TICK Or PERF_DELTA_COUNTER Or PERF_DISPLAY_PERCENT)

' Queue Length Space-Time Product. Divide delta by delta time. No Display Suffix.
Public Const PERF_COUNTER_QUEUELEN_TYPE = (PERF_SIZE_DWORD Or PERF_TYPE_COUNTER Or PERF_COUNTER_QUEUELEN Or PERF_TIMER_TICK Or PERF_DELTA_COUNTER Or PERF_DISPLAY_NO_SUFFIX)

' 64-bit Counter.  Divide delta by delta time. Display Suffix: "/sec"
Public Const PERF_COUNTER_BULK_COUNT = (PERF_SIZE_LARGE Or PERF_TYPE_COUNTER Or PERF_COUNTER_RATE Or PERF_TIMER_TICK Or PERF_DELTA_COUNTER Or PERF_DISPLAY_PER_SEC)

' Indicates the counter is not a  counter but rather Unicode text Display as text.
Public Const PERF_COUNTER_TEXT = (PERF_SIZE_VARIABLE_LEN Or PERF_TYPE_TEXT Or PERF_TEXT_UNICODE Or PERF_DISPLAY_NO_SUFFIX)

' Indicates the data is a counter  which should not be
' time averaged on display (such as an error counter on a serial line)
' Display as is.  No Display Suffix.
Public Const PERF_COUNTER_RAWCOUNT = (PERF_SIZE_DWORD Or PERF_TYPE_NUMBER Or PERF_NUMBER_DECIMAL Or PERF_DISPLAY_NO_SUFFIX)

' A count which is either 1 or 0 on each sampling interrupt (% busy)
' Divide delta by delta base. Display Suffix: "%"
Public Const PERF_SAMPLE_FRACTION = (PERF_SIZE_DWORD Or PERF_TYPE_COUNTER Or PERF_COUNTER_FRACTION Or PERF_DELTA_COUNTER Or PERF_DELTA_BASE Or PERF_DISPLAY_PERCENT)

' A count which is sampled on each sampling interrupt (queue length)
' Divide delta by delta time. No Display Suffix.
Public Const PERF_SAMPLE_COUNTER = (PERF_SIZE_DWORD Or PERF_TYPE_COUNTER Or PERF_COUNTER_RATE Or PERF_TIMER_TICK Or PERF_DELTA_COUNTER Or PERF_DISPLAY_NO_SUFFIX)

' A label: no data is associated with this counter (it has 0 length)
' Do not display.
Public Const PERF_COUNTER_NODATA = (PERF_SIZE_ZERO Or PERF_DISPLAY_NOSHOW)

' 64-bit Timer inverse (e.g., idle is measured, but display busy  As Integer)
' Display 100 - delta divided by delta time.  Display suffix: "%"
Public Const PERF_COUNTER_TIMER_INV = (PERF_SIZE_LARGE Or PERF_TYPE_COUNTER Or PERF_COUNTER_RATE Or PERF_TIMER_TICK Or PERF_DELTA_COUNTER Or PERF_INVERSE_COUNTER Or PERF_DISPLAY_PERCENT)

' The divisor for a sample, used with the previous counter to form a
' sampled %.  You must check for >0 before dividing by this!  This
' counter will directly follow the  numerator counter.  It should not
' be displayed to the user.
Public Const PERF_SAMPLE_BASE = (PERF_SIZE_DWORD Or PERF_TYPE_COUNTER Or PERF_COUNTER_BASE Or PERF_DISPLAY_NOSHOW Or &H1)         '  for compatibility with pre-beta versions

' A timer which, when divided by an average base, produces a time
' in seconds which is the average time of some operation.  This
' timer times total operations, and  the base is the number of opera-
' tions.  Display Suffix: "sec"
Public Const PERF_AVERAGE_TIMER = (PERF_SIZE_DWORD Or PERF_TYPE_COUNTER Or PERF_COUNTER_FRACTION Or PERF_DISPLAY_SECONDS)

' Used as the denominator in the computation of time or count
' averages.  Must directly follow the numerator counter.  Not dis-
' played to the user.
Public Const PERF_AVERAGE_BASE = (PERF_SIZE_DWORD Or PERF_TYPE_COUNTER Or PERF_COUNTER_BASE Or PERF_DISPLAY_NOSHOW Or &H2)         '  for compatibility with pre-beta versions

' A bulk count which, when divided (typically) by the number of
' operations, gives (typically) the number of bytes per operation.
' No Display Suffix.
Public Const PERF_AVERAGE_BULK = (PERF_SIZE_LARGE Or PERF_TYPE_COUNTER Or PERF_COUNTER_FRACTION Or PERF_DISPLAY_NOSHOW)

' 64-bit Timer in 100 nsec units. Display delta divided by
' delta time.  Display suffix: "%"
Public Const PERF_100NSEC_TIMER = (PERF_SIZE_LARGE Or PERF_TYPE_COUNTER Or PERF_COUNTER_RATE Or PERF_TIMER_100NS Or PERF_DELTA_COUNTER Or PERF_DISPLAY_PERCENT)

' 64-bit Timer inverse (e.g., idle is measured, but display busy  As Integer)
' Display 100 - delta divided by delta time.  Display suffix: "%"
Public Const PERF_100NSEC_TIMER_INV = (PERF_SIZE_LARGE Or PERF_TYPE_COUNTER Or PERF_COUNTER_RATE Or PERF_TIMER_100NS Or PERF_DELTA_COUNTER Or PERF_INVERSE_COUNTER Or PERF_DISPLAY_PERCENT)

' 64-bit Timer.  Divide delta by delta time.  Display suffix: "%"
' Timer for multiple instances, so result can exceed 100%.
Public Const PERF_COUNTER_MULTI_TIMER = (PERF_SIZE_LARGE Or PERF_TYPE_COUNTER Or PERF_COUNTER_RATE Or PERF_DELTA_COUNTER Or PERF_TIMER_TICK Or PERF_MULTI_COUNTER Or PERF_DISPLAY_PERCENT)

' 64-bit Timer inverse (e.g., idle is measured, but display busy  As Integer)
' Display 100  _MULTI_BASE - delta divided by delta time.
' Display suffix: "%" Timer for multiple instances, so result
' can exceed 100%.  Followed by a counter of type _MULTI_BASE.
Public Const PERF_COUNTER_MULTI_TIMER_INV = (PERF_SIZE_LARGE Or PERF_TYPE_COUNTER Or PERF_COUNTER_RATE Or PERF_DELTA_COUNTER Or PERF_MULTI_COUNTER Or PERF_TIMER_TICK Or PERF_INVERSE_COUNTER Or PERF_DISPLAY_PERCENT)

' Number of instances to which the preceding _MULTI_..._INV counter
' applies.  Used as a factor to get the percentage.
Public Const PERF_COUNTER_MULTI_BASE = (PERF_SIZE_LARGE Or PERF_TYPE_COUNTER Or PERF_COUNTER_BASE Or PERF_MULTI_COUNTER Or PERF_DISPLAY_NOSHOW)

' 64-bit Timer in 100 nsec units. Display delta divided by delta time.
' Display suffix: "%" Timer for multiple instances, so result can exceed 100%.
Public Const PERF_100NSEC_MULTI_TIMER = (PERF_SIZE_LARGE Or PERF_TYPE_COUNTER Or PERF_DELTA_COUNTER Or PERF_COUNTER_RATE Or PERF_TIMER_100NS Or PERF_MULTI_COUNTER Or PERF_DISPLAY_PERCENT)

' 64-bit Timer inverse (e.g., idle is measured, but display busy  As Integer)
' Display 100  _MULTI_BASE - delta divided by delta time.
' Display suffix: "%" Timer for multiple instances, so result
' can exceed 100%.  Followed by a counter of type _MULTI_BASE.
Public Const PERF_100NSEC_MULTI_TIMER_INV = (PERF_SIZE_LARGE Or PERF_TYPE_COUNTER Or PERF_DELTA_COUNTER Or PERF_COUNTER_RATE Or PERF_TIMER_100NS Or PERF_MULTI_COUNTER Or PERF_INVERSE_COUNTER Or PERF_DISPLAY_PERCENT)

' Indicates the data is a fraction of the following counter  which
' should not be time averaged on display (such as free space over
' total space.) Display as is.  Display the quotient as "%".
Public Const PERF_RAW_FRACTION = (PERF_SIZE_DWORD Or PERF_TYPE_COUNTER Or PERF_COUNTER_FRACTION Or PERF_DISPLAY_PERCENT)

' Indicates the data is a base for the preceding counter which should
' not be time averaged on display (such as free space over total space.)
Public Const PERF_RAW_BASE = (PERF_SIZE_DWORD Or PERF_TYPE_COUNTER Or PERF_COUNTER_BASE Or PERF_DISPLAY_NOSHOW Or &H3)         '  for compatibility with pre-beta versions

' The data collected in this counter is actually the start time of the
' item being measured. For display, this data is subtracted from the
' sample time to yield the elapsed time as the difference between the two.
' In the definition below, the PerfTime field of the Object contains
' the sample time as indicated by the PERF_OBJECT_TIMER bit and the
' difference is scaled by the PerfFreq of the Object to convert the time
' units into seconds.
Public Const PERF_ELAPSED_TIME = (PERF_SIZE_LARGE Or PERF_TYPE_COUNTER Or PERF_COUNTER_ELAPSED Or PERF_OBJECT_TIMER Or PERF_DISPLAY_SECONDS)

' The following counter type can be used with the preceding types to
' define a range of values to be displayed in a histogram.
Public Const PERF_COUNTER_HISTOGRAM_TYPE = &H80000000  ' Counter begins or ends a histogram

' The following are used to determine the level of detail associated
' with the counter.  The user will be setting the level of detail
' that should be displayed at any given time.
Public Const PERF_DETAIL_NOVICE = 100   '  The uninformed can understand it
Public Const PERF_DETAIL_ADVANCED = 200 '  For the advanced user
Public Const PERF_DETAIL_EXPERT = 300   '  For the expert user
Public Const PERF_DETAIL_WIZARD = 400   '  For the system designer

'================mPriveleges.bas================
'Set debug priveleges to this process
'(required to access HKEY_DYN_DATA registry key)
'===============================================

Option Explicit

Private Const SE_DEBUG_NAME = "SeDebugPrivilege"
Private Const SE_PRIVILEGE_ENABLED = &H2
Private Const ANYSIZE_ARRAY = 1
Private Const TOKEN_ADJUST_PRIVILEGES = &H20
Private Const TOKEN_QUERY = &H8

Private Type LARGE_INTEGER
  LowPart As Long
  HighPart As Long
End Type

Private Type LUID_AND_ATTRIBUTES
  pLuid As LARGE_INTEGER
  Attributes As Long
End Type

Private Type TOKEN_PRIVILEGES
  PrivilegeCount As Long
  Privileges(ANYSIZE_ARRAY) As LUID_AND_ATTRIBUTES
End Type

Private Declare Function OpenProcessToken Lib "advapi32.dll" ( _
  ByVal ProcessHandle As Long, _
  ByVal DesiredAccess As Long, _
  TokenHandle As Long) As Long

Private Declare Function LookupPrivilegeValue Lib "advapi32.dll" _
  Alias "LookupPrivilegeValueA" ( _
  ByVal lpSystemName As String, _
  ByVal lpName As String, _
  lpLuid As LARGE_INTEGER) As Long

Private Declare Function AdjustTokenPrivileges Lib "advapi32" ( _
  ByVal TokenHandle As Long, _
  ByVal DisableAllPrivileges As Long, _
  ByRef NewState As TOKEN_PRIVILEGES, _
  ByVal BufferLength As Long, _
  ByRef PreviousState As Any, _
  ByRef ReturnLength As Any) As Long

Private Declare Function GetCurrentProcess Lib "kernel32" () As Long

Public Function EnableDebugPrivNT() As Boolean
  Dim hToken As Long
  Dim li As LARGE_INTEGER
  Dim tkp As TOKEN_PRIVILEGES
 
  If OpenProcessToken(GetCurrentProcess, TOKEN_ADJUST_PRIVILEGES _
                      Or TOKEN_QUERY, hToken) = 0 Then Exit Function
 
  If LookupPrivilegeValue("", SE_DEBUG_NAME, li) = 0 Then Exit Function
 
  tkp.PrivilegeCount = 1
  tkp.Privileges(0).pLuid = li
  tkp.Privileges(0).Attributes = SE_PRIVILEGE_ENABLED
 
  EnableDebugPrivNT = AdjustTokenPrivileges(hToken, False, tkp, 0, ByVal 0&, 0)
End Function

'================mRegistry.bas================
'Registry access API to read specific values
'=============================================

Option Explicit
 
Public Declare Function RegQueryValueEx Lib "advapi32.dll" Alias "RegQueryValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal lpReserved As Long, lpType As Long, lpData As Any, lpcbData As Long) As Long
Public Declare Function RegOpenKeyEx Lib "advapi32.dll" Alias "RegOpenKeyExA" (ByVal hKey As Long, ByVal lpSubKey As String, ByVal ulOptions As Long, ByVal samDesired As Long, phkResult As Long) As Long
Public Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) As Long

Public Const PerfLibKey = "Software\Microsoft\Windows NT\CurrentVersion\Perflib\009"

Public Const HKEY_LOCAL_MACHINE As Long = &H80000002
Public Const HKEY_PERFORMANCE_DATA As Long = &H80000004

Public Const ERROR_SUCCESS       As Long = 0
Public Const ERROR_ACCESS_DENIED As Long = 5
Public Const ERROR_MORE_DATA     As Long = 234
Public Const ERROR_NO_MORE_ITEMS As Long = 259

Public Const STANDARD_RIGHTS_ALL = &H1F0000
Public Const KEY_QUERY_VALUE = &H1
Public Const KEY_SET_VALUE = &H2
Public Const KEY_CREATE_SUB_KEY = &H4
Public Const KEY_ENUMERATE_SUB_KEYS = &H8
Public Const KEY_NOTIFY = &H10
Public Const KEY_CREATE_LINK = &H20
Public Const SYNCHRONIZE = &H100000
Public Const KEY_ALL_ACCESS = ((STANDARD_RIGHTS_ALL _
                             Or KEY_QUERY_VALUE _
                             Or KEY_SET_VALUE _
                             Or KEY_CREATE_SUB_KEY _
                             Or KEY_ENUMERATE_SUB_KEYS _
                             Or KEY_NOTIFY Or KEY_CREATE_LINK) _
                           And (Not SYNCHRONIZE))
Public Const KEY_READ = &H20019  ' ((READ_CONTROL Or KEY_QUERY_VALUE Or
                                 ' KEY_ENUMERATE_SUB_KEYS Or KEY_NOTIFY)
                                 ' And (Not SYNCHRONIZE))

Public Const REG_NONE As Long = 0                     ' No data
Public Const REG_SZ As Long = 1                       ' nul terminated string
Public Const REG_EXPAND_SZ As Long = 2                ' nul terminated string w/enviornment var
Public Const REG_BINARY As Long = 3                   ' Free form binary
Public Const REG_DWORD As Long = 4                    ' 32-bit number
Public Const REG_DWORD_LITTLE_ENDIAN As Long = 4      ' 32-bit number (same as REG_DWORD)
Public Const REG_DWORD_BIG_ENDIAN As Long = 5         ' 32-bit number
Public Const REG_LINK As Long = 6                     ' Symbolic Link (unicode)
Public Const REG_MULTI_SZ As Long = 7                 ' Multiple Unicode strings
Public Const REG_RESOURCE_LIST As Long = 8            ' Resource list in the resource map
Public Const REG_FULL_RESOURCE_DESCRIPTOR As Long = 9 ' Resource list in the hardware description
Public Const REG_RESOURCE_REQUIREMENTS_LIST As Long = 10

'========================================
'                   FORMS (2 TOTAL)
' Copy/Paste source into notepad and save
' as frmTaskList.frm and frmSettings.frm
'========================================

'=============frmTaskList=====================
VERSION 5.00
Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "Mscomctl.ocx"
Begin VB.Form frmTaskList
   Caption         =   "Form1"
   ClientHeight    =   4860
   ClientLeft      =   165
   ClientTop       =   855
   ClientWidth     =   7005
   LinkTopic       =   "Form1"
   ScaleHeight     =   4860
   ScaleWidth      =   7005
   StartUpPosition =   3  'Windows Default
   Begin VB.Timer Timer1
      Left            =   600
      Top             =   4320
   End
   Begin MSComctlLib.ListView lvProcesses
      Height          =   4095
      Left            =   120
      TabIndex        =   0
      Top             =   120
      Width           =   6735
      _ExtentX        =   11880
      _ExtentY        =   7223
      View            =   3
      LabelEdit       =   1
      LabelWrap       =   -1  'True
      HideSelection   =   0   'False
      FullRowSelect   =   -1  'True
      _Version        =   393217
      ForeColor       =   -2147483640
      BackColor       =   -2147483643
      BorderStyle     =   1
      Appearance      =   1
      NumItems        =   4
      BeginProperty ColumnHeader(1) {BDD1F052-858B-11D1-B16A-00C0F0283628}
         Text            =   "Image name"
         Object.Width           =   2540
      EndProperty
      BeginProperty ColumnHeader(2) {BDD1F052-858B-11D1-B16A-00C0F0283628}
         SubItemIndex    =   1
         Text            =   "User name"
         Object.Width           =   2540
      EndProperty
      BeginProperty ColumnHeader(3) {BDD1F052-858B-11D1-B16A-00C0F0283628}
         SubItemIndex    =   2
         Text            =   "Perf"
         Object.Width           =   2540
      EndProperty
      BeginProperty ColumnHeader(4) {BDD1F052-858B-11D1-B16A-00C0F0283628}
         SubItemIndex    =   3
         Text            =   "Memory"
         Object.Width           =   2540
      EndProperty
   End
   Begin VB.Menu mnuView
      Caption         =   "View"
      Begin VB.Menu mnuColumns
         Caption         =   "Columns"
      End
      Begin VB.Menu mnuFrequency
         Caption         =   "Refresh frequency"
         Begin VB.Menu mnuFreq
            Caption         =   "High (1 sec)"
            Index           =   0
         End
         Begin VB.Menu mnuFreq
            Caption         =   "Medium (5 sec)"
            Checked         =   -1  'True
            Index           =   1
         End
         Begin VB.Menu mnuFreq
            Caption         =   "Low (10 sec)"
            Index           =   2
         End
         Begin VB.Menu mnuFreq
            Caption         =   "Freeze"
            Index           =   3
         End
      End
   End
End
Attribute VB_Name = "frmTaskList"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit

Dim Freq(3) As Long
Dim Time_Freq As Long
Private Declare Sub InitCommonControls Lib "comctl32" () 'For XP style

Public Sub RefreshView(lv As ListView, Optional bUpdateList As Boolean)
   Dim pdb As PERF_DATA_BLOCK
   Dim pot As PERF_OBJECT_TYPE
   Dim pcd() As PERF_COUNTER_DEFINITION
   Dim pid() As PERF_INSTANCE_DEFINITION
   Dim pcb() As PERF_COUNTER_BLOCK
   
   Dim nCounters As Long, nInstances As Long
   Dim lpOffset As Long, lpCntOffset As Long, lpDefOffset As Long
   Dim i As Long, j As Long, CounterId As Long, cnt As Long
   Dim abData() As Byte
   Dim sInfo As String, s As String
   Dim wdt As Long, hgt As Long, dwSize As Long, lTemp As Long, liTemp As LARGE_INTEGER, curTemp As Currency
   Dim li As ListItem
   
   Static LastVal() As Currency
   Static LastTime As SYSTEMTIME
   Static bTimeInit As Boolean
   Dim DeltaT As Single
   
   abData = GetPerfData(counters.Process)

   CopyMemory pdb, abData(0), Len(pdb)
   If (pdb.HeaderLength = 0) Or (pdb.NumObjectTypes = 0) Then Exit Sub
   
   If Not bTimeInit Then
      DeltaT = Timer1.Interval / 1000
   Else
      DeltaT = (pdb.SysTime.wHour - LastTime.wHour) * 3600 + _
               (pdb.SysTime.wMinute - LastTime.wMinute) * 60 + _
               (pdb.SysTime.wSecond - LastTime.wSecond) + _
               (pdb.SysTime.wMilliseconds - LastTime.wMilliseconds) / 1000
   End If
   lpOffset = pdb.HeaderLength
   CopyMemory pot, abData(lpOffset), LenB(pot)
   
   nCounters = pot.NumCounters
   nInstances = pot.NumInstances
   If (nCounters < 1) Or (nInstances < 1) Then Exit Sub
   
   ReDim pcd(nCounters - 1)
   ReDim pid(nInstances - 1)
   ReDim pcb(nInstances - 1)
   
   lpCntOffset = lpOffset + pot.HeaderLength
   Time_Freq = pot.PerfFreq.LowPart
   CopyMemory pcd(0), abData(lpCntOffset), Len(pcd(0)) * nCounters
   If Not frmSettings.bInitDone Then
      wdt = frmSettings.chkSettings(i).Width
      hgt = frmSettings.chkSettings(i).Height
      For j = 0 To nCounters - 1
          CounterId = pcd(j).CounterNameTitleIndex
          Load frmSettings.chkSettings(j + 1)
          frmSettings.chkSettings(j).Move Int(j / 14) * wdt + 300, (j Mod 14) * hgt * 1.5 + 300
          frmSettings.chkSettings(j + 1).Enabled = True
          frmSettings.chkSettings(j + 1).value = 0
          frmSettings.chkSettings(j + 1).Caption = g_colCounters(CStr(CounterId))
          frmSettings.chkSettings(j + 1).Tag = CounterId
          frmSettings.chkSettings(j + 1).Visible = True
      Next j
      frmSettings.bInitDone = True
   End If
   lv.Enabled = False
   If bUpdateList Then
      lv.ListItems.Clear
      lv.ColumnHeaders.Clear
      For i = 0 To frmSettings.chkSettings.Count - 1
          If frmSettings.chkSettings(i).value = 1 Then
             If i > 0 Then
                lv.ColumnHeaders.Add , , Replace(frmSettings.chkSettings(i).Caption, "%", ""), 1800, 1
             Else
                lv.ColumnHeaders.Add , , Replace(frmSettings.chkSettings(i).Caption, "%", ""), 1800
             End If
          End If
      Next i
      ReDim LastVal(1 To lv.ColumnHeaders.Count, nInstances - 1)
   End If
   lpDefOffset = lpOffset + pot.DefinitionLength
   For i = 0 To nInstances - 1
       CopyMemory pid(i), abData(lpDefOffset), Len(pid(0))
       s = String(pid(i).NameLength, 0)
       CopyMemory ByVal StrPtr(s), abData(lpDefOffset + pid(i).NameOffset), pid(i).NameLength
       lpDefOffset = lpDefOffset + pid(i).ByteLength
       
       If bUpdateList Then
          Set li = lv.ListItems.Add(, , TrimNull(s))
       Else
          If i > lv.ListItems.Count - 1 Then
             Set li = lv.ListItems.Add(, , TrimNull(s))
             ReDim LastVal(1 To lv.ColumnHeaders.Count, nInstances - 1)
          Else
             Set li = lv.ListItems(i + 1)
          End If
       End If
       If i = nInstances - 1 Then
          li.Bold = True
          li.ForeColor = vbRed
       End If
       cnt = 0
       For j = 0 To UBound(pcd)
           If frmSettings.chkSettings(j + 1).value = 1 Then
              cnt = cnt + 1
              dwSize = pcd(j).CounterSize
              curTemp = 0
              If dwSize > 0 Then
                 CopyMemory curTemp, abData(lpDefOffset + pcd(j).CounterOffset), dwSize
              End If
              s = TranslateCounter(curTemp * 10000#, LastVal(cnt, i) * 10000#, DeltaT, dwSize, pcd(j).CounterType)
              Select Case pcd(j).CounterNameTitleIndex
                 Case 56, 58, 172 To 186 'bytes
                    s = FormatByteSize(CCur(s))
                 Case 682                'priority
                    s = TranslatePriority(CLng(s))
                 Case Else
              End Select
              li.SubItems(cnt) = s
              LastVal(cnt, i) = curTemp
           End If
       Next j
       
       CopyMemory pcb(i), abData(lpDefOffset), Len(pcb(0))
       lpDefOffset = lpDefOffset + pcb(i).ByteLength
   Next i
   LastTime = pdb.SysTime
   If Not bTimeInit Then bTimeInit = True
   Set li = Nothing
   lv.Enabled = True
End Sub

Private Sub Form_Initialize()
   InitCommonControls
End Sub

Private Sub Form_Load()
   Caption = "VB process list"
   Set g_colCounters = New Collection
   Freq(0) = 1000
   Freq(1) = 5000
   Freq(2) = 10000
   Freq(3) = 0
   InitCounters
   RefreshView lvProcesses, True
   Timer1.Interval = Freq(1)
   Timer1.Enabled = True
End Sub

Private Sub Form_Resize()
   If WindowState = vbMinimized Then Exit Sub
   lvProcesses.Move 0, 0, ScaleWidth, ScaleHeight
End Sub

Private Sub Form_Unload(Cancel As Integer)
   Set g_colCounters = Nothing
   Unload frmSettings
   Set frmSettings = Nothing
End Sub

Private Sub mnuColumns_Click()
   Timer1.Enabled = False
   frmSettings.Show vbModal
   Timer1.Enabled = True
End Sub

Private Sub mnuFreq_Click(Index As Integer)
   Dim i As Long
   For i = 0 To 3
      mnuFreq(i).Checked = False
      mnuFreq(Index).Checked = True
   Next i
   Timer1.Interval = Freq(Index)
   Timer1.Enabled = (Index < 3)
End Sub

Private Sub Timer1_Timer()
   RefreshView lvProcesses
End Sub

Private Function TranslateCounter(ByVal NewVal As Variant, _
                                  ByVal LastVal As Variant, _
                                  ByVal DeltaT As Single, _
                                  ByVal cntSize As Long, _
                                  ByVal cntType As Long) As String
   Dim s As String, suffix As String
   Dim dwSize As Long, dwType As Long, dwSubType As Long
   Dim dwTimerType As Long, dwSuffix As Long
   Dim dwFreq As Long, delta As Variant
   dwSize = cntType And &H300
   If dwSize = PERF_SIZE_ZERO Then Exit Function
   dwSuffix = cntType And &H70000000
   Select Case dwSuffix
      Case PERF_DISPLAY_NO_SUFFIX: suffix = ""
      Case PERF_DISPLAY_PER_SEC:   suffix = "" '"/sec"
      Case PERF_DISPLAY_PERCENT:   suffix = "%"
      Case PERF_DISPLAY_SECONDS:   suffix = "" '" secs"
      Case PERF_DISPLAY_NOSHOW:    suffix = "" '" (hidden)"
   End Select
   dwType = cntType And &HC00
   Select Case dwType
          Case PERF_TYPE_NUMBER
               dwSubType = cntType And &H30000
               Select Case dwSubType
                  Case PERF_NUMBER_HEX      '  display as HEX value
                       TranslateCounter = "0x" & Hex(NewVal)
                  Case PERF_NUMBER_DEC_1000 '  display as a decimal/1000
                       TranslateCounter = CStr(NewVal / 1000)
                  Case PERF_NUMBER_DECIMAL '  display as a decimal
                       TranslateCounter = CStr(NewVal)
                  Case Else                 '  display as a decimal integer
                       TranslateCounter = CStr(NewVal)
               End Select
          Case PERF_TYPE_COUNTER
               dwSubType = cntType And &H70000
               Select Case dwSubType
                      Case PERF_COUNTER_VALUE                '  display counter value
                           TranslateCounter = CStr(NewVal)
                      Case PERF_COUNTER_RATE                 '  divide ctr / delta time
                           dwTimerType = cntType And &H300000
                           Select Case dwTimerType
                              Case PERF_TIMER_TICK
                                   dwFreq = 1000
                              Case PERF_OBJECT_TIMER
                                   dwFreq = Time_Freq
                              Case PERF_TIMER_100NS
                                   dwFreq = 10000000
                              Case Else
                           End Select
                           If LastVal = 0 Then LastVal = NewVal
                           delta = NewVal - LastVal
                           delta = Int(delta / DeltaT / dwFreq * 100)
                           If (cntType And PERF_INVERSE_COUNTER) = PERF_INVERSE_COUNTER Then
                              delta = 100 - delta
                           End If
                           TranslateCounter = delta
                      Case PERF_COUNTER_FRACTION             '  divide ctr / base
                      Case PERF_COUNTER_BASE                 '  base value used in fractions
                      Case PERF_COUNTER_ELAPSED              '  subtract counter from current time
                           TranslateCounter = CDate(Time - FileTimeToVBTime(NewVal))
                      Case PERF_COUNTER_QUEUELEN             '  Use Queuelen processing func.
                      Case PERF_COUNTER_HISTOGRAM            '  Counter begins or ends a histogram
                      Case Else
               End Select
          Case PERF_TYPE_TEXT
          Case PERF_TYPE_ZERO
               TranslateCounter = "0": Exit Function
   End Select
   TranslateCounter = TranslateCounter & suffix
End Function

Private Function TranslatePriority(ByVal priority As Long) As String
   Dim s As String
   Select Case priority
       Case 0:        s = "Unknown"
       Case 1:        s = "Idle"
       Case 2 To 4:   s = "Low"
       Case 5 To 7:   s = "Below normal"
       Case 8 To 10:  s = "Normal"
       Case 11, 12:   s = "Above normal"
       Case 13 To 20: s = "High"
       Case Else:     s = "Real time"
   End Select
   s = s & " (" & CStr(priority) & ")"
   TranslatePriority = s
End Function

'===============frmSettings.frm==============
VERSION 5.00
Begin VB.Form frmSettings
   BorderStyle     =   1  'Fixed Single
   Caption         =   "Form1"
   ClientHeight    =   6480
   ClientLeft      =   45
   ClientTop       =   435
   ClientWidth     =   6180
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   6480
   ScaleWidth      =   6180
   StartUpPosition =   3  'Windows Default
   Begin VB.CommandButton Command4
      Caption         =   "Deselect all"
      Height          =   375
      Left            =   1200
      TabIndex        =   5
      Top             =   6000
      Width           =   1095
   End
   Begin VB.CommandButton Command3
      Caption         =   "Select all"
      Height          =   375
      Left            =   120
      TabIndex        =   4
      Top             =   6000
      Width           =   975
   End
   Begin VB.CommandButton Command2
      Caption         =   "&Cancel"
      Height          =   375
      Left            =   4680
      TabIndex        =   3
      Top             =   6000
      Width           =   1335
   End
   Begin VB.CommandButton Command1
      Caption         =   "&OK"
      Height          =   375
      Left            =   3240
      TabIndex        =   2
      Top             =   6000
      Width           =   1335
   End
   Begin VB.Frame Frame1
      Caption         =   "Display columns"
      Height          =   5775
      Left            =   120
      TabIndex        =   0
      Top             =   120
      Width           =   5895
      Begin VB.CheckBox chkSettings
         Caption         =   "Image name"
         Enabled         =   0   'False
         Height          =   255
         Index           =   0
         Left            =   240
         TabIndex        =   1
         Top             =   360
         Value           =   1  'Checked
         Width           =   2775
      End
   End
End
Attribute VB_Name = "frmSettings"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Public bInitDone As Boolean
Dim bShowColumns() As Boolean

Private Sub Command1_Click()
   Dim i As Long
   ReDim bShowColumns(chkSettings.Count - 1)
   For i = 0 To chkSettings.Count - 1
      bShowColumns(i) = CBool(chkSettings(i).value)
   Next i
   frmTaskList.RefreshView frmTaskList.lvProcesses, True
   Me.Hide
End Sub

Private Sub Command2_Click()
   Dim i As Long
   If UBound(bShowColumns) < chkSettings.Count - 1 Then
      ReDim bShowColumns(chkSettings.Count - 1)
      bShowColumns(0) = True
   End If
   For i = 0 To chkSettings.Count - 1
      chkSettings(i).value = Abs(bShowColumns(i))
   Next i
   Me.Hide
End Sub

Private Sub Command3_Click()
   Dim i As Long
   For i = 1 To chkSettings.Count - 1
       chkSettings(i).value = 1
   Next i
End Sub

Private Sub Command4_Click()
   Dim i As Long
   For i = 1 To chkSettings.Count - 1
       chkSettings(i).value = 0
   Next i
End Sub

Private Sub Form_Load()
   Caption = "Task list columns"
   ReDim bShowColumns(0)
   bShowColumns(0) = True
End Sub

Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
   If UnloadMode = vbFormControlMenu Then
      Cancel = True
      Me.Hide
   End If
End Sub

Private Sub Form_Unload(Cancel As Integer)
   Erase bShowColumns
End Sub
0
 

Author Comment

by:ocsscott
ID: 16691936
2 problems in task manager i need the column CPU Time

and your code cpu% is ver 100% so something deosnt work could it be hyperthreading?  

but I really need to see the CPU Time
0
 

Accepted Solution

by:
GranMod earned 0 total points
ID: 16949538
PAQed with points refunded (500)

GranMod
Community Support Moderator
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question