home *** CD-ROM | disk | FTP | other *** search
/ Planet Source Code Jumbo …e CD Visual Basic 1 to 7 / 1_2002.ISO / Data / Zips / CODE_UPLOAD77177122000.psc / Form1.frm (.txt) next >
Encoding:
Visual Basic Form  |  2000-07-12  |  23.5 KB  |  629 lines

  1. VERSION 5.00
  2. Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCTL.OCX"
  3. Begin VB.Form Form1 
  4.    AutoRedraw      =   -1  'True
  5.    BackColor       =   &H00C0C0C0&
  6.    BorderStyle     =   1  'Fixed Single
  7.    Caption         =   "Advanced Task Manager"
  8.    ClientHeight    =   7275
  9.    ClientLeft      =   150
  10.    ClientTop       =   720
  11.    ClientWidth     =   10425
  12.    ControlBox      =   0   'False
  13.    Icon            =   "Form1.frx":0000
  14.    LinkTopic       =   "Form1"
  15.    MaxButton       =   0   'False
  16.    MinButton       =   0   'False
  17.    ScaleHeight     =   7275
  18.    ScaleWidth      =   10425
  19.    StartUpPosition =   3  'Windows Default
  20.    Begin VB.CommandButton Command2 
  21.       Caption         =   "Update"
  22.       Height          =   255
  23.       Left            =   5640
  24.       TabIndex        =   8
  25.       Top             =   720
  26.       Width           =   2295
  27.    End
  28.    Begin VB.CommandButton Command1 
  29.       Caption         =   "Minimize to tray"
  30.       Height          =   255
  31.       Left            =   3360
  32.       TabIndex        =   7
  33.       Top             =   720
  34.       Width           =   2055
  35.    End
  36.    Begin Project1.TrayArea tIcon 
  37.       Left            =   6720
  38.       Top             =   6600
  39.       _ExtentX        =   900
  40.       _ExtentY        =   900
  41.       Icon            =   "Form1.frx":0442
  42.    End
  43.    Begin MSComctlLib.StatusBar StatusBar1 
  44.       Align           =   2  'Align Bottom
  45.       Height          =   255
  46.       Left            =   0
  47.       TabIndex        =   6
  48.       Top             =   7020
  49.       Width           =   10425
  50.       _ExtentX        =   18389
  51.       _ExtentY        =   450
  52.       _Version        =   393216
  53.       BeginProperty Panels {8E3867A5-8586-11D1-B16A-00C0F0283628} 
  54.          NumPanels       =   2
  55.          BeginProperty Panel1 {8E3867AB-8586-11D1-B16A-00C0F0283628} 
  56.             Object.Width           =   3528
  57.             MinWidth        =   3528
  58.          EndProperty
  59.          BeginProperty Panel2 {8E3867AB-8586-11D1-B16A-00C0F0283628} 
  60.          EndProperty
  61.       EndProperty
  62.       BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
  63.          Name            =   "MS Sans Serif"
  64.          Size            =   8.25
  65.          Charset         =   177
  66.          Weight          =   700
  67.          Underline       =   0   'False
  68.          Italic          =   0   'False
  69.          Strikethrough   =   0   'False
  70.       EndProperty
  71.    End
  72.    Begin VB.ComboBox Combo1 
  73.       BackColor       =   &H00E0E0E0&
  74.       ForeColor       =   &H00000000&
  75.       Height          =   315
  76.       Left            =   120
  77.       TabIndex        =   5
  78.       Text            =   "Loaded files(s)"
  79.       Top             =   720
  80.       Width           =   3015
  81.    End
  82.    Begin MSComctlLib.Toolbar Toolbar1 
  83.       Align           =   1  'Align Top
  84.       Height          =   570
  85.       Left            =   0
  86.       TabIndex        =   3
  87.       Top             =   0
  88.       Width           =   10425
  89.       _ExtentX        =   18389
  90.       _ExtentY        =   1005
  91.       ButtonWidth     =   1773
  92.       ButtonHeight    =   953
  93.       Appearance      =   1
  94.       Style           =   1
  95.       ImageList       =   "ImageList1"
  96.       DisabledImageList=   "ImageList1"
  97.       HotImageList    =   "ImageList1"
  98.       _Version        =   393216
  99.       BeginProperty Buttons {66833FE8-8583-11D1-B16A-00C0F0283628} 
  100.          NumButtons      =   5
  101.          BeginProperty Button1 {66833FEA-8583-11D1-B16A-00C0F0283628} 
  102.             Caption         =   "Run..."
  103.             Key             =   "run"
  104.             ImageIndex      =   1
  105.          EndProperty
  106.          BeginProperty Button2 {66833FEA-8583-11D1-B16A-00C0F0283628} 
  107.             Caption         =   "Close"
  108.             Key             =   "close"
  109.             ImageIndex      =   8
  110.          EndProperty
  111.          BeginProperty Button3 {66833FEA-8583-11D1-B16A-00C0F0283628} 
  112.             Style           =   3
  113.          EndProperty
  114.          BeginProperty Button4 {66833FEA-8583-11D1-B16A-00C0F0283628} 
  115.             Style           =   3
  116.          EndProperty
  117.          BeginProperty Button5 {66833FEA-8583-11D1-B16A-00C0F0283628} 
  118.             Caption         =   "Shut down..."
  119.             Key             =   "shut"
  120.             ImageIndex      =   7
  121.          EndProperty
  122.       EndProperty
  123.    End
  124.    Begin MSComctlLib.ProgressBar pb1 
  125.       Height          =   255
  126.       Left            =   120
  127.       TabIndex        =   1
  128.       Top             =   6480
  129.       Width           =   9615
  130.       _ExtentX        =   16960
  131.       _ExtentY        =   450
  132.       _Version        =   393216
  133.       BorderStyle     =   1
  134.       Appearance      =   0
  135.       Scrolling       =   1
  136.    End
  137.    Begin VB.Timer Timer2 
  138.       Interval        =   1000
  139.       Left            =   9360
  140.       Top             =   6120
  141.    End
  142.    Begin MSComctlLib.ImageList ImageList1 
  143.       Left            =   600
  144.       Top             =   2880
  145.       _ExtentX        =   1005
  146.       _ExtentY        =   1005
  147.       BackColor       =   -2147483643
  148.       ImageWidth      =   16
  149.       ImageHeight     =   16
  150.       MaskColor       =   12632256
  151.       _Version        =   393216
  152.       BeginProperty Images {2C247F25-8591-11D1-B16A-00C0F0283628} 
  153.          NumListImages   =   8
  154.          BeginProperty ListImage1 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  155.             Picture         =   "Form1.frx":0894
  156.             Key             =   "task"
  157.          EndProperty
  158.          BeginProperty ListImage2 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  159.             Picture         =   "Form1.frx":3048
  160.             Key             =   "verinfo"
  161.          EndProperty
  162.          BeginProperty ListImage3 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  163.             Picture         =   "Form1.frx":349C
  164.             Key             =   "startime"
  165.          EndProperty
  166.          BeginProperty ListImage4 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  167.             Picture         =   "Form1.frx":3BF0
  168.             Key             =   ""
  169.          EndProperty
  170.          BeginProperty ListImage5 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  171.             Picture         =   "Form1.frx":63A4
  172.             Key             =   ""
  173.          EndProperty
  174.          BeginProperty ListImage6 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  175.             Picture         =   "Form1.frx":8B58
  176.             Key             =   ""
  177.          EndProperty
  178.          BeginProperty ListImage7 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  179.             Picture         =   "Form1.frx":B30C
  180.             Key             =   ""
  181.          EndProperty
  182.          BeginProperty ListImage8 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  183.             Picture         =   "Form1.frx":DAC0
  184.             Key             =   ""
  185.          EndProperty
  186.       EndProperty
  187.    End
  188.    Begin VB.Timer Timer1 
  189.       Enabled         =   0   'False
  190.       Interval        =   2000
  191.       Left            =   6960
  192.       Top             =   5040
  193.    End
  194.    Begin MSComctlLib.ListView Windowlist 
  195.       Height          =   5175
  196.       Left            =   120
  197.       TabIndex        =   4
  198.       Top             =   1080
  199.       Visible         =   0   'False
  200.       Width           =   9615
  201.       _ExtentX        =   16960
  202.       _ExtentY        =   9128
  203.       View            =   3
  204.       Sorted          =   -1  'True
  205.       LabelWrap       =   -1  'True
  206.       HideSelection   =   -1  'True
  207.       PictureAlignment=   1
  208.       _Version        =   393217
  209.       Icons           =   "ImageList1"
  210.       SmallIcons      =   "ImageList1"
  211.       ColHdrIcons     =   "ImageList1"
  212.       ForeColor       =   -2147483624
  213.       BackColor       =   8421376
  214.       BorderStyle     =   1
  215.       Appearance      =   1
  216.       BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
  217.          Name            =   "Arial"
  218.          Size            =   8.25
  219.          Charset         =   0
  220.          Weight          =   700
  221.          Underline       =   0   'False
  222.          Italic          =   0   'False
  223.          Strikethrough   =   0   'False
  224.       EndProperty
  225.       NumItems        =   1
  226.       BeginProperty ColumnHeader(1) {BDD1F052-858B-11D1-B16A-00C0F0283628} 
  227.          Text            =   "Window"
  228.          Object.Width           =   7056
  229.       EndProperty
  230.    End
  231.    Begin MSComctlLib.ListView Tasklist 
  232.       Height          =   5175
  233.       Left            =   120
  234.       TabIndex        =   0
  235.       Top             =   1080
  236.       Width           =   9615
  237.       _ExtentX        =   16960
  238.       _ExtentY        =   9128
  239.       View            =   3
  240.       LabelWrap       =   -1  'True
  241.       HideSelection   =   -1  'True
  242.       PictureAlignment=   1
  243.       _Version        =   393217
  244.       Icons           =   "ImageList1"
  245.       SmallIcons      =   "ImageList1"
  246.       ColHdrIcons     =   "ImageList1"
  247.       ForeColor       =   -2147483624
  248.       BackColor       =   8421376
  249.       BorderStyle     =   1
  250.       Appearance      =   1
  251.       BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
  252.          Name            =   "Arial"
  253.          Size            =   8.25
  254.          Charset         =   0
  255.          Weight          =   700
  256.          Underline       =   0   'False
  257.          Italic          =   0   'False
  258.          Strikethrough   =   0   'False
  259.       EndProperty
  260.       NumItems        =   3
  261.       BeginProperty ColumnHeader(1) {BDD1F052-858B-11D1-B16A-00C0F0283628} 
  262.          Text            =   "Task"
  263.          Object.Width           =   7056
  264.       EndProperty
  265.       BeginProperty ColumnHeader(2) {BDD1F052-858B-11D1-B16A-00C0F0283628} 
  266.          SubItemIndex    =   1
  267.          Text            =   "Version"
  268.          Object.Width           =   2540
  269.       EndProperty
  270.       BeginProperty ColumnHeader(3) {BDD1F052-858B-11D1-B16A-00C0F0283628} 
  271.          SubItemIndex    =   2
  272.          Text            =   "No. of Threads"
  273.          Object.Width           =   2540
  274.       EndProperty
  275.       Picture         =   "Form1.frx":DF14
  276.    End
  277.    Begin VB.Label Label1 
  278.       Caption         =   "CPU usage:"
  279.       ForeColor       =   &H00C00000&
  280.       Height          =   255
  281.       Left            =   120
  282.       TabIndex        =   2
  283.       Top             =   6240
  284.       Width           =   1575
  285.    End
  286.    Begin VB.Menu file 
  287.       Caption         =   "File"
  288.       NegotiatePosition=   2  'Middle
  289.       Begin VB.Menu min 
  290.          Caption         =   "Minimize to system tray"
  291.       End
  292.       Begin VB.Menu ex 
  293.          Caption         =   "Exit"
  294.       End
  295.    End
  296.    Begin VB.Menu about 
  297.       Caption         =   "About..."
  298.    End
  299. Attribute VB_Name = "Form1"
  300. Attribute VB_GlobalNameSpace = False
  301. Attribute VB_Creatable = False
  302. Attribute VB_PredeclaredId = True
  303. Attribute VB_Exposed = False
  304. Option Explicit
  305. Public User_name As String
  306. Const REG_DWORD = 4
  307. Const HKEY_DYN_DATA = &H80000006
  308. Private Declare Function GetWindow Lib "user32" _
  309. (ByVal hwnd As Long, ByVal wCmd As Long) As Long
  310. Private Declare Function GetParent Lib "user32" _
  311. (ByVal hwnd As Long) As Long
  312. Private Declare Function GetWindowTextLength Lib _
  313. "user32" Alias "GetWindowTextLengthA" (ByVal hwnd As Long) As Long
  314. Private Declare Function GetWindowText Lib "user32" _
  315. Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal _
  316. lpString As String, ByVal cch As Long) As Long
  317. Const GW_HWNDFIRST = 0
  318. Const GW_HWNDNEXT = 2
  319. Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
  320. Private Declare Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
  321. Private 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
  322. Private Declare Function RegOpenKey Lib "advapi32.dll" Alias "RegOpenKeyA" (ByVal hKey As Long, ByVal lpSubKey As String, phkResult As Long) As Long
  323. Private Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) As Long
  324. Private Declare Sub ExitProcess Lib "kernel32" (ByVal uExitCode As Long)
  325. Private Const VER_PLATFORM_WIN32s = 0
  326. Private Const VER_PLATFORM_WIN32_WINDOWS = 1
  327. Private Const VER_PLATFORM_WIN32_NT = 2
  328. 'Private Type OSVERSIONINFO
  329. '    dwOSVersionInfoSize As Long
  330.  '   dwMajorVersion      As Long
  331.   '  dwMinorVersion      As Long
  332.   '  dwBuildNumber       As Long
  333.    ' dwPlatformId        As Long
  334.    ' szCSDVersion        As String * 128
  335. 'End Type
  336. Private Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long
  337. Private Type MEMORYSTATUS
  338.     dwLength        As Long ' sizeof(MEMORYSTATUS)
  339.     dwMemoryLoad    As Long ' percent of memory in use
  340.     dwTotalPhys     As Long ' bytes of physical memory
  341.     dwAvailPhys     As Long ' free physical memory bytes
  342.     dwTotalPageFile As Long ' bytes of paging file
  343.     dwAvailPageFile As Long ' free bytes of paging file
  344.     dwTotalVirtual  As Long ' user bytes of address space
  345.     dwAvailVirtual  As Long ' free user bytes
  346. End Type
  347. Private Declare Sub GlobalMemoryStatus Lib "kernel32" (lpBuffer As MEMORYSTATUS)
  348. 'Private Declare Function GetVersionEx Lib "kernel32" Alias "GetVersionExA" (lpVersionInformation As OSVERSIONINFO) As Long
  349. Private Const TH32CS_SNAPPROCESS As Long = 2&
  350. Private Const MAX_PATH As Integer = 260
  351. Private Type PROCESSENTRY32
  352.   dwSize As Long
  353.   cntUsage As Long
  354.   th32ProcessID As Long
  355.   th32DefaultHeapID As Long
  356.   th32ModuleID As Long
  357.   cntThreads As Long
  358.   th32ParentProcessID As Long
  359.   pcPriClassBase As Long
  360.   dwFlags As Long
  361.   szExeFile As String * MAX_PATH
  362. End Type
  363. Private Declare Function CreateToolhelpSnapshot Lib "kernel32" _
  364. Alias "CreateToolhelp32Snapshot" _
  365. (ByVal lFlags As Long, ByVal lProcessID As Long) As Long
  366. Private Declare Function ProcessFirst Lib "kernel32" _
  367. Alias "Process32First" _
  368. (ByVal hSnapShot As Long, uProcess As PROCESSENTRY32) As Long
  369. Private Declare Function ProcessNext Lib "kernel32" _
  370. Alias "Process32Next" _
  371. (ByVal hSnapShot As Long, uProcess As PROCESSENTRY32) As Long
  372. Private Declare Sub CloseHandle Lib "kernel32" _
  373. (ByVal hPass As Long)
  374. Private Declare Function TerminateProcess Lib "kernel32" (ByVal hProcess As Long, ByVal uExitCode As Long) As Long
  375. Private Type VS_FIXEDFILEINFO
  376.    dwSignature As Long
  377.    dwStrucVersionl As Integer     '  e.g. = &h0000 = 0
  378.    dwStrucVersionh As Integer     '  e.g. = &h0042 = .42
  379.    dwFileVersionMSl As Integer    '  e.g. = &h0003 = 3
  380.    dwFileVersionMSh As Integer    '  e.g. = &h0075 = .75
  381.    dwFileVersionLSl As Integer    '  e.g. = &h0000 = 0
  382.    dwFileVersionLSh As Integer    '  e.g. = &h0031 = .31
  383.    dwProductVersionMSl As Integer '  e.g. = &h0003 = 3
  384.    dwProductVersionMSh As Integer '  e.g. = &h0010 = .1
  385.    dwProductVersionLSl As Integer '  e.g. = &h0000 = 0
  386.    dwProductVersionLSh As Integer '  e.g. = &h0031 = .31
  387.    dwFileFlagsMask As Long        '  = &h3F for version "0.42"
  388.    dwFileFlags As Long            '  e.g. VFF_DEBUG Or VFF_PRERELEASE
  389.    dwFileOS As Long               '  e.g. VOS_DOS_WINDOWS16
  390.    dwFileType As Long             '  e.g. VFT_DRIVER
  391.    dwFileSubtype As Long          '  e.g. VFT2_DRV_KEYBOARD
  392.    dwFileDateMS As Long           '  e.g. 0
  393.    dwFileDateLS As Long           '  e.g. 0
  394. End Type
  395. Private Declare Function SHShutDownDialog Lib "shell32" Alias "#60" (ByVal YourGuess As Long) As Long
  396. Const shrdNoMRUString = &H2    '2nd bit is set
  397. Private Declare Function SHRunDialog Lib "shell32" Alias "#61" (ByVal hOwner As Long, ByVal Unknown1 As Long, ByVal Unknown2 As Long, ByVal szTitle As String, ByVal szPrompt As String, ByVal uFlags As Long) As Long
  398. Private Declare Function GetFileVersionInfo Lib "Version.dll" Alias "GetFileVersionInfoA" (ByVal lptstrFilename As String, ByVal dwhandle As Long, ByVal dwlen As Long, lpData As Any) As Long
  399. Private Declare Function GetFileVersionInfoSize Lib "Version.dll" Alias "GetFileVersionInfoSizeA" (ByVal lptstrFilename As String, lpdwHandle As Long) As Long
  400. Private Declare Function VerQueryValue Lib "Version.dll" Alias "VerQueryValueA" (pBlock As Any, ByVal lpSubBlock As String, lplpBuffer As Any, puLen As Long) As Long
  401. Private Declare Sub MoveMemory Lib "kernel32" Alias "RtlMoveMemory" (dest As Any, ByVal Source As Long, ByVal Length As Long)
  402. Dim Filename As String, Directory As String, FullFileName As String
  403. Dim StrucVer As String, FileVer As String, ProdVer As String
  404. Dim FileFlags As String, FileOS As String, FileType As String, FileSubType As String
  405. Private Sub DisplayVerInfo() ' Used Api guide ( www.allapi.com)
  406.    Dim rc As Long, lDummy As Long, sBuffer() As Byte
  407.    Dim lBufferLen As Long, lVerPointer As Long, udtVerBuffer As VS_FIXEDFILEINFO
  408.    Dim lVerbufferLen As Long
  409.    '*** Get size ****
  410.    lBufferLen = GetFileVersionInfoSize(FullFileName, lDummy) ' if 0 is returned then there's no info
  411.    If lBufferLen < 1 Then
  412.       Exit Sub
  413.    End If
  414.    '**** Store info to udtVerBuffer struct ****
  415.    ReDim sBuffer(lBufferLen)
  416.    rc = GetFileVersionInfo(FullFileName, 0&, lBufferLen, sBuffer(0))
  417.    rc = VerQueryValue(sBuffer(0), "\", lVerPointer, lVerbufferLen)
  418.    MoveMemory udtVerBuffer, lVerPointer, Len(udtVerBuffer)
  419.    '**** Determine File Version number ****
  420.    FileVer = Format$(udtVerBuffer.dwFileVersionMSh) & "." & Format$(udtVerBuffer.dwFileVersionMSl) & "." & Format$(udtVerBuffer.dwFileVersionLSh) & "." & Format$(udtVerBuffer.dwFileVersionLSl)
  421.    '**** Determine Product Version number ****
  422.    ProdVer = Format$(udtVerBuffer.dwProductVersionMSh) & "." & Format$(udtVerBuffer.dwProductVersionMSl) & "." & Format$(udtVerBuffer.dwProductVersionLSh) & "." & Format$(udtVerBuffer.dwProductVersionLSl)
  423. End Sub
  424. Private Sub Check1_Click()
  425. End Sub
  426. Sub fillwindowList()
  427. Windowlist.ListItems.Clear
  428. Dim CurrWnd As Long
  429. Dim Length As Long
  430. Dim TaskName As String
  431. Dim parent As Long
  432. CurrWnd = GetWindow(Form1.hwnd, GW_HWNDFIRST)
  433. While CurrWnd <> 0
  434. parent = GetParent(CurrWnd)
  435. Length = GetWindowTextLength(CurrWnd)
  436. TaskName = Space$(Length + 1)
  437. Length = GetWindowText(CurrWnd, TaskName, Length + 1)
  438. TaskName = Left$(TaskName, Len(TaskName) - 1)
  439. If Length > 0 Then
  440. '    If TaskName <> Me.Caption Then
  441.      '   If TaskName <> "taskmon" Then
  442.    Windowlist.ListItems.Add , , TaskName, 5, 5
  443.   '      End If
  444.   '  End If
  445. End If
  446. CurrWnd = GetWindow(CurrWnd, GW_HWNDNEXT)
  447. DoEvents
  448. End Sub
  449. Private Sub about_Click()
  450. Form2.Show
  451. End Sub
  452. Private Sub Combo1_Click()
  453. If Combo1.Text = "Open window(s)" Then
  454. Listswitch Tasklist
  455. Exit Sub
  456. End If
  457. Listswitch Windowlist
  458. End Sub
  459. Private Sub Combo1_Scroll()
  460. If Combo1.Text = "Open window(s)" Then
  461. Listswitch Tasklist
  462. Else: Listswitch (Windowlist)
  463. End If
  464. End Sub
  465. Private Sub Command1_Click()
  466. Form1.Hide
  467. tIcon.Visible = True
  468. tIcon.ToolTip = "One Click To Activate Task Manager -  Takes a few seconds"
  469. End Sub
  470. Private Sub Command2_Click()
  471. Call Timer1_Timer
  472. Call fillwindowList
  473. End Sub
  474. Private Sub ex_Click()
  475. ' Quit
  476. tIcon.Visible = False
  477. End Sub
  478. Private Sub Form_Load()
  479. On Error GoTo erro
  480. Tasklist.Picture = LoadPicture()
  481. Combo1.AddItem "Loaded file(s)"
  482. Combo1.AddItem "Open window(s)"
  483. Dim rv, x As Long
  484. ' get user name
  485. User_name = String(100, Chr$(0))
  486. GetUserName User_name, 100
  487. User_name = Left$(User_name, InStr(User_name, Chr$(0)) - 1)
  488. StatusBar1.Panels(2).Text = "User : " & User_name
  489. Tasklist.ListItems.Clear
  490. ' take snap shot of loaded files
  491. Dim nstr As String
  492. Dim hSnapShot As Long
  493. Dim uProcess As PROCESSENTRY32
  494. Dim r As Long
  495. 'List.AddItem " Running Tasks: "
  496. hSnapShot = CreateToolhelpSnapshot(TH32CS_SNAPPROCESS, 0&)
  497. If hSnapShot = 0 Then
  498.   Exit Sub
  499. End If
  500. uProcess.dwSize = Len(uProcess)
  501. r = ProcessFirst(hSnapShot, uProcess)
  502. Do While r
  503.  nstr = uProcess.szExeFile
  504.  Tasklist.ListItems.Add , , nstr, 1, 1
  505. FullFileName = nstr
  506. DisplayVerInfo
  507.  Tasklist.ListItems.Item(Tasklist.ListItems.Count).ListSubItems.Add , , FileVer, 2, ""
  508.  Tasklist.ListItems.Item(Tasklist.ListItems.Count).ListSubItems.Add , , uProcess.cntThreads, 4, ""
  509.   r = ProcessNext(hSnapShot, uProcess)
  510. Loop ' Do all the processs
  511. Call CloseHandle(hSnapShot)
  512. '*-----------------------------------CPU USAGE REG VAL'S INIT -----------------------------*
  513.     Dim lData As Long
  514.     Dim lType As Long
  515.     Dim lSize As Long
  516.     Dim hKey As Long
  517.     Dim Qry As String
  518.     Qry = RegOpenKey(HKEY_DYN_DATA, "PerfStats\StartStat", hKey)
  519.     If Qry <> 0 Then
  520.             MsgBox "Could not open registery!"
  521.         End
  522.     End If
  523.     lType = REG_DWORD
  524.     lSize = 4
  525.     Qry = RegQueryValueEx(hKey, "KERNEL\CPUUsage", 0, lType, lData, lSize)
  526.     Qry = RegCloseKey(hKey)
  527. Exit Sub
  528. erro:
  529. MsgBox Err.Description
  530. End Sub
  531. Private Sub min_Click()
  532. Form1.Hide
  533. tIcon.Visible = True
  534. End Sub
  535. Private Sub tIcon_MouseDown(Button As Integer)
  536. '--  UPDATE & SHOW FORM
  537. Call Timer1_Timer
  538. Call fillwindowList
  539. Form1.Show
  540. End Sub
  541. Private Sub Timer1_Timer()
  542. Tasklist.ListItems.Clear
  543. Dim nstr As String
  544. Dim hSnapShot As Long
  545. Dim uProcess As PROCESSENTRY32
  546. Dim r As Long
  547. hSnapShot = CreateToolhelpSnapshot(TH32CS_SNAPPROCESS, 0&)
  548. If hSnapShot = 0 Then
  549.   Exit Sub
  550. End If
  551. uProcess.dwSize = Len(uProcess)
  552. r = ProcessFirst(hSnapShot, uProcess)
  553. Do While r
  554.  nstr = uProcess.szExeFile
  555.  Tasklist.ListItems.Add , , nstr, 1, 1
  556. FullFileName = nstr
  557. DisplayVerInfo
  558.  Tasklist.ListItems.Item(Tasklist.ListItems.Count).ListSubItems.Add , , FileVer, 2, ""
  559.  Tasklist.ListItems.Item(Tasklist.ListItems.Count).ListSubItems.Add , , uProcess.cntThreads, 4, ""
  560.   r = ProcessNext(hSnapShot, uProcess)
  561. Call CloseHandle(hSnapShot)
  562. End Sub
  563. Private Sub Timer2_Timer()
  564.  '--- needed for cpu usage - found it on PSC long ago
  565.  Dim lData As Long
  566.     Dim lType As Long
  567.     Dim lSize As Long
  568.     Dim hKey As Long
  569.     Dim Qry As String
  570.     Dim usg As Long
  571.                   
  572.     Qry = RegOpenKey(HKEY_DYN_DATA, "PerfStats\StatData", hKey)
  573.                 
  574.     If Qry <> 0 Then
  575.             MsgBox "Could not open registery!"
  576.         End
  577.     End If
  578.                 
  579.     lType = REG_DWORD
  580.     lSize = 4
  581.                 
  582.     Qry = RegQueryValueEx(hKey, "KERNEL\CPUUsage", 0, lType, lData, lSize)
  583.     usg = Int(lData)
  584.          pb1.Max = 100
  585.          pb1.Value = usg
  586.          pb1.ToolTipText = "CPU usage : " & usg & "%"
  587. Qry = RegCloseKey(hKey)
  588. If Tasklist.Visible = True Then
  589. StatusBar1.Panels(1).Text = Tasklist.ListItems.Count & " File(s) Loaded"
  590. End If
  591. If Windowlist.Visible = True Then
  592. StatusBar1.Panels(1).Text = Windowlist.ListItems.Count & " Window(s) open"
  593. End If
  594. End Sub
  595. Private Sub Toolbar1_ButtonClick(ByVal Button As MSComctlLib.Button)
  596. If Button.Key = "shut" Then
  597. SHShutDownDialog 0
  598. End If
  599. If Button.Key = "run" Then
  600. SHRunDialog Form1.hwnd, 0, 0, Me.Caption & " - new task", "Enter the path: ", 0
  601. End If
  602. If Button.Key = "close" Then
  603. Dim confirmation As VbMsgBoxResult
  604. Dim winHwnd As Long
  605. Dim RetVal As Long
  606. If Windowlist.SelectedItem = "" Then Exit Sub
  607. winHwnd = FindWindow(vbNullString, Windowlist.SelectedItem)
  608. If winHwnd <> 0 Then
  609. confirmation = MsgBox("Are you sure you would like to close the window : " & Windowlist.SelectedItem, vbCritical + vbYesNo, "Close Task")
  610. If confirmation <> vbYes Then Exit Sub
  611. RetVal = PostMessage(winHwnd, &H10, 0&, 0&)
  612. Call fillwindowList
  613. If RetVal = 0 Then
  614. MsgBox "Error posting message."
  615. End If
  616. Else: MsgBox Windowlist.SelectedItem + " is not open."
  617. End If
  618. End If
  619. End Sub
  620. Public Function Listswitch(curlist As ListView)
  621. If curlist.Name = "Tasklist" Then
  622. Tasklist.Visible = False
  623. Windowlist.Visible = True
  624. Call fillwindowList
  625. Else: Tasklist.Visible = True
  626. Windowlist.Visible = False
  627. End If
  628. End Function
  629.