home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Toolbox / Visual Basic Toolbox (P.I.E.)(1996).ISO / toolkit / db3stuff / form1.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1995-08-03  |  5.5 KB  |  169 lines

  1. VERSION 2.00
  2. Begin Form Form1 
  3.    BackColor       =   &H00C0C0C0&
  4.    Caption         =   "DBAppMon v1.1 Demo"
  5.    ClientHeight    =   3540
  6.    ClientLeft      =   1350
  7.    ClientTop       =   3000
  8.    ClientWidth     =   7650
  9.    Height          =   3945
  10.    Left            =   1290
  11.    LinkTopic       =   "Form1"
  12.    ScaleHeight     =   3540
  13.    ScaleWidth      =   7650
  14.    Top             =   2655
  15.    Width           =   7770
  16.    Begin CommandButton cmdHelp 
  17.       BackColor       =   &H00C0C0C0&
  18.       Caption         =   "&?"
  19.       Height          =   372
  20.       Left            =   6660
  21.       TabIndex        =   5
  22.       Top             =   3000
  23.       Width           =   432
  24.    End
  25.    Begin CommandButton cmdNotepad 
  26.       BackColor       =   &H00C0C0C0&
  27.       Caption         =   "&Notepad"
  28.       Height          =   375
  29.       Left            =   5280
  30.       TabIndex        =   4
  31.       Top             =   3000
  32.       Width           =   1215
  33.    End
  34.    Begin CommandButton cmdTaskList 
  35.       BackColor       =   &H00C0C0C0&
  36.       Caption         =   "Show all &tasks"
  37.       Height          =   375
  38.       Left            =   1740
  39.       TabIndex        =   3
  40.       Top             =   3000
  41.       Width           =   1455
  42.    End
  43.    Begin CommandButton cmdModules 
  44.       BackColor       =   &H00C0C0C0&
  45.       Caption         =   "Show all &modules"
  46.       Height          =   375
  47.       Left            =   3360
  48.       TabIndex        =   2
  49.       Top             =   3000
  50.       Width           =   1755
  51.    End
  52.    Begin CommandButton cmdMonitor 
  53.       BackColor       =   &H00C0C0C0&
  54.       Caption         =   "&Start monitor"
  55.       Height          =   375
  56.       Left            =   300
  57.       TabIndex        =   1
  58.       Top             =   3000
  59.       Width           =   1275
  60.    End
  61.    Begin ListBox List1 
  62.       Height          =   2760
  63.       Left            =   60
  64.       TabIndex        =   0
  65.       Top             =   60
  66.       Width           =   7455
  67.    End
  68.    Begin DBAppMon DBAppMon1 
  69.       Left            =   60
  70.       ModuleLookupName=   ""
  71.       Top             =   2820
  72.    End
  73. Option Explicit
  74. Sub AddToBox (x As String)
  75.   If List1.ListCount > 100 Then List1.RemoveItem 0
  76.   List1.AddItem Format$(Now, "HH:MM") + "  " + x
  77. End Sub
  78. Sub cmdHelp_Click ()
  79.   Dim S As String
  80.   S = "DBAppMon is able to monitor application and DLL "
  81.   S = S + "startup and exit and generates VB events when "
  82.   S = S + " this happens. It also has several properties "
  83.   S = S + "for retrieving various information about loaded "
  84.   S = S + "tasks and DLLs. Furthermore, there are properties for "
  85.   S = S + "retrieving version info from executables. (To try this "
  86.   S = S + "feature, double click a line in the list box containing "
  87.   S = S + "a file name.) For more information, please refer to "
  88.   S = S + """DBAPPMON.WRI.""" + Chr$(13) + Chr$(10) + Chr$(13) + Chr$(10)
  89.   S = S + "DBAppMon was written by Dan Bystr
  90. m." + Chr$(13) + Chr$(10)
  91.   S = S + "e-mail: ""dan.bystrom@adb-partner.it-invest.se"""
  92.   MsgBox S, 0, "About DBAppMon"
  93. End Sub
  94. Sub cmdModules_Click ()
  95.   Dim S As String
  96.   Dim i As Integer, m As Integer
  97.   List1.Clear
  98.   S = DBAppMon1.AllModules
  99.     m = Val(Mid$(S, i + 1))
  100.     List1.AddItem MyHex(m) + " " + DBAppMon1.ModuleFileName(m) + "  Usage: " & DBAppMon1.ModuleUsage(m)
  101.     i = InStr(i + 1, S, ",")
  102.     If i = 0 Then Exit Do
  103.   Loop
  104. End Sub
  105. Sub cmdMonitor_Click ()
  106.   DBAppMon1.Monitor = Not DBAppMon1.Monitor
  107.   If DBAppMon1.Monitor Then
  108.     cmdMonitor.Caption = "&Stop monitor"
  109.     List1.Clear
  110.   Else
  111.     cmdMonitor.Caption = "&Start monitor"
  112.   End If
  113. End Sub
  114. Sub cmdNotepad_Click ()
  115.   List1.AddItem "Returned from Shell function: " & MyHex(Shell("notepad.exe"))
  116. End Sub
  117. Sub cmdTaskList_Click ()
  118.   Dim S As String
  119.   Dim i As Integer, t As Integer
  120.   List1.Clear
  121.   S = DBAppMon1.AllTasks
  122.     t = Val(Mid$(S, i + 1))
  123.     List1.AddItem MyHex(t) + " " + DBAppMon1.TaskFileName(t) + "  Parent: " & MyHex(DBAppMon1.TaskParent(t))
  124.     i = InStr(i + 1, S, ",")
  125.     If i = 0 Then Exit Do
  126.   Loop
  127. End Sub
  128. Sub DBAppMon1_AppExit (hTask As Integer, nExitCode As Integer)
  129.   AddToBox "AppExit code= " & nExitCode & " (" & MyHex(hTask) & ")"
  130. End Sub
  131. Sub DBAppMon1_AppStart (hTask As Integer)
  132.   AddToBox "AppStart (" & MyHex(hTask) & ") hInst: " & MyHex(DBAppMon1.TaskInstance(hTask)) & " " & DBAppMon1.TaskFileName(hTask) & "  Parent: " & MyHex(DBAppMon1.TaskParent(hTask))
  133. End Sub
  134. Sub DBAppMon1_DLLExit (hModule As Integer)
  135.   AddToBox "DLLExit (" & MyHex(hModule) & ")"
  136. End Sub
  137. Sub DBAppMon1_DLLStart (hModule As Integer)
  138.   AddToBox "DLLStart (" & MyHex(hModule) & ") " & DBAppMon1.ModuleFileName(hModule)
  139. End Sub
  140. Sub DBAppMon1_TaskIn (hTask As Integer)
  141.   AddToBox "TaskIn (" & MyHex(hTask) & ")"
  142. End Sub
  143. Sub Form_Load ()
  144.   List1.AddItem "This application was started from " & DBAppMon1.TaskFileName(DBAppMon1.TaskParent(DBAppMon1.MyTask))
  145. End Sub
  146. Sub List1_DblClick ()
  147.   Dim FN As String, i As Integer
  148.   FN = List1.List(List1.ListIndex)
  149.   i = InStr(FN, ":\")
  150.   If i < 2 Then
  151.     MsgBox "This line doesn't contain a file name!", 48
  152.     Exit Sub
  153.   End If
  154.   FN = Mid$(FN, i - 1)
  155.   i = InStr(FN, " ")
  156.   If i Then FN = Left$(FN, i - 1)
  157.   On Error Resume Next
  158.   DBAppMon1.VerReadInfo = FN
  159.   If Err Then
  160.     MsgBox "The file """ + FN + """ doesn't contain any version info!", 48
  161.     Exit Sub
  162.   End If
  163.   Form2.Show 1
  164.   DBAppMon1.VerReadInfo = ""
  165. End Sub
  166. Function MyHex (ByVal h As Integer) As String
  167.   MyHex = "$" + Right$("000" + Hex$(h), 4)
  168. End Function
  169.