home *** CD-ROM | disk | FTP | other *** search
/ Dan Appleman's Visual Bas…s Guide to the Win32 API / Dan.Applmans.Visual.Basic.5.0.Programmers.Guide.To.The.Win32.API.1997.Ziff-Davis.Press.CD / VB5PG32.mdf / articles / vbdev / source / tasklook.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1996-01-22  |  3.7 KB  |  106 lines

  1. VERSION 4.00
  2. Begin VB.Form Form1 
  3.    Appearance      =   0  'Flat
  4.    BackColor       =   &H80000005&
  5.    Caption         =   "Task Lister"
  6.    ClientHeight    =   3300
  7.    ClientLeft      =   1095
  8.    ClientTop       =   1485
  9.    ClientWidth     =   5175
  10.    BeginProperty Font 
  11.       name            =   "MS Sans Serif"
  12.       charset         =   1
  13.       weight          =   700
  14.       size            =   8.25
  15.       underline       =   0   'False
  16.       italic          =   0   'False
  17.       strikethrough   =   0   'False
  18.    EndProperty
  19.    ForeColor       =   &H80000008&
  20.    Height          =   3705
  21.    Left            =   1035
  22.    LinkTopic       =   "Form1"
  23.    ScaleHeight     =   3300
  24.    ScaleWidth      =   5175
  25.    Top             =   1140
  26.    Width           =   5295
  27.    Begin VB.CommandButton cmd_Notify 
  28.       Appearance      =   0  'Flat
  29.       BackColor       =   &H80000005&
  30.       Caption         =   "Set Notification"
  31.       Height          =   495
  32.       Left            =   3360
  33.       TabIndex        =   2
  34.       Top             =   1080
  35.       Width           =   1455
  36.    End
  37.    Begin VBX.ccCallback Callback1 
  38.       EventTrigger    =   1  'Posted
  39.       IntVersion      =   5
  40.       Left            =   3660
  41.       Top             =   2400
  42.       Type            =   6  'EnumWindows
  43.    End
  44.    Begin VB.CommandButton ListTasks 
  45.       Appearance      =   0  'Flat
  46.       BackColor       =   &H80000005&
  47.       Caption         =   "List Tasks"
  48.       Height          =   495
  49.       Left            =   3360
  50.       TabIndex        =   1
  51.       Top             =   360
  52.       Width           =   1455
  53.    End
  54.    Begin VB.ListBox lst_Tasks 
  55.       Appearance      =   0  'Flat
  56.       Height          =   2565
  57.       Left            =   240
  58.       TabIndex        =   0
  59.       Top             =   360
  60.       Width           =   2835
  61.    End
  62. Attribute VB_Name = "Form1"
  63. Attribute VB_Creatable = False
  64. Attribute VB_Exposed = False
  65. Option Explicit
  66. Private Sub Callback1_EnumWindows(hWnd As Integer, lpData As Long, retval As Integer)
  67.     lst_Tasks.AddItem Notifications(hWnd)
  68. End Sub
  69. Private Sub cmd_Notify_Click()
  70.     Dim di%
  71.     di% = NotifyRegister(0, Callback1.ProcAddress, NF_NORMAL)
  72. End Sub
  73. Private Sub Form_Load()
  74.     Notifications$(0) = "NFY_UNKNOWN"   ' Unknown notification
  75.     Notifications$(1) = "NFY_LOADSEG"   ' A segment is being loaded
  76.     Notifications$(2) = "NFY_FREESEG"   ' A segment is being freed
  77.     Notifications$(3) = "NFY_STARTDLL"  ' A DLL is being loaded
  78.     Notifications$(4) = "NFY_STARTTASK" ' A task is being started
  79.     Notifications$(5) = "NFY_EXITTASK"  ' A task is ending
  80.     Notifications$(6) = "NFY_DELMODULE" ' A module is being freed
  81.     Notifications$(7) = "NFY_RIP"       ' A fatal system error occured
  82.     Notifications$(8) = "NFY_TASKIN"    ' Switch to a task
  83.     Notifications$(9) = "NFY_TASKOUT"   ' Switch from a task
  84.     Notifications$(10) = "NFY_INCHAR"   ' A character is entered
  85.     Notifications$(11) = "NFY_OUTSTR"   ' Debugging string output
  86.     Notifications$(12) = "NFY_LOGERROR" ' API error occured (not fatal)
  87.     Notifications$(13) = "NFY_LOGPARAMERROR"    ' An API parameter error was detected
  88. End Sub
  89. Private Sub Form_Unload(Cancel As Integer)
  90.     NotifyUnRegister 0
  91. End Sub
  92. ' Fill the list box with the names and handles of tasks
  93. Private Sub ListTasks_Click()
  94.     Dim success%
  95.     Dim te As TASKENTRY
  96.     lst_Tasks.Clear ' Clear the list box
  97.     ' It is very important to initialize the value of
  98.     ' the size field in the structure.
  99.     te.dwSize = Len(te)
  100.     success% = TaskFirst(te)
  101.     Do While success%
  102.         lst_Tasks.AddItem GetModuleName$(te) & " " & Hex$(te.hTask)
  103.         success% = TaskNext(te)
  104.     Loop
  105. End Sub
  106.