home *** CD-ROM | disk | FTP | other *** search
/ Programming Tool Box / SIMS_2.iso / vb_code1 / at_spy / main.frm < prev    next >
Text File  |  1994-06-16  |  4KB  |  149 lines

  1. VERSION 2.00
  2. Begin Form frmMain 
  3.    BackColor       =   &H00C0C0C0&
  4.    BorderStyle     =   1  'Fixed Single
  5.    Caption         =   "VB App.Title Spy"
  6.    ClientHeight    =   1215
  7.    ClientLeft      =   1095
  8.    ClientTop       =   1635
  9.    ClientWidth     =   4935
  10.    Height          =   1620
  11.    Icon            =   MAIN.FRX:0000
  12.    Left            =   1035
  13.    LinkTopic       =   "Form1"
  14.    MaxButton       =   0   'False
  15.    MinButton       =   0   'False
  16.    ScaleHeight     =   1215
  17.    ScaleWidth      =   4935
  18.    Top             =   1290
  19.    Width           =   5055
  20.    Begin CommandButton cmdAppTitle 
  21.       BackColor       =   &H00C0C0C0&
  22.       Caption         =   "&Get App.Title"
  23.       Default         =   -1  'True
  24.       Enabled         =   0   'False
  25.       Height          =   375
  26.       Left            =   1200
  27.       TabIndex        =   3
  28.       Top             =   720
  29.       Width           =   2055
  30.    End
  31.    Begin CommandButton cmdBrowse 
  32.       BackColor       =   &H00C0C0C0&
  33.       Caption         =   "&Browse..."
  34.       Height          =   375
  35.       Left            =   3360
  36.       TabIndex        =   4
  37.       Top             =   720
  38.       Width           =   1335
  39.    End
  40.    Begin CommonDialog cmdOpen 
  41.       CancelError     =   -1  'True
  42.       DefaultExt      =   "*.exe"
  43.       DialogTitle     =   "Browse"
  44.       Filter          =   "Executables (*.EXE)"
  45.       Flags           =   4100
  46.       Left            =   2040
  47.       Top             =   1680
  48.    End
  49.    Begin SSPanel Panel3D1 
  50.       AutoSize        =   3  'AutoSize Child To Panel
  51.       BevelOuter      =   1  'Inset
  52.       Height          =   330
  53.       Left            =   1200
  54.       TabIndex        =   1
  55.       Top             =   240
  56.       Width           =   3495
  57.       Begin TextBox txtFilename 
  58.          Height          =   300
  59.          Left            =   15
  60.          TabIndex        =   2
  61.          Top             =   15
  62.          Width           =   3465
  63.       End
  64.    End
  65.    Begin Label Label1 
  66.       AutoSize        =   -1  'True
  67.       BackColor       =   &H00C0C0C0&
  68.       Caption         =   "&Filename:"
  69.       Height          =   195
  70.       Left            =   240
  71.       TabIndex        =   0
  72.       Top             =   240
  73.       Width           =   825
  74.    End
  75. End
  76.  
  77. Sub cmdAppTitle_Click ()
  78.  
  79.     Dim sErrMsg As String
  80.     Dim sAppTitle As String
  81.  
  82.     On Error Resume Next
  83.  
  84.     ' Get the App.Title of the given file.
  85.     sAppTitle = GetAppTitle(txtFileName)
  86.  
  87.     ' If there was no error then display the title retrieved.
  88.     If Err = 0 Then
  89.  
  90.         MsgBox "App.Title of " & txtFileName & " is:" & Chr$(13) & Chr$(10) & sAppTitle, MB_ICONINFORMATION
  91.  
  92.     Else
  93.  
  94.         ' Was it a Visual Basic trappable error?
  95.         If Err < GATERR_FIRST Or Err > GATERR_LAST Then
  96.             
  97.             sErrMsg = Error$
  98.     
  99.         Else
  100.             
  101.             ' Determine the error string using the
  102.             ' custom error code returned by GetAppTitle().
  103.             Select Case Err
  104.     
  105.                 Case GATERR_NOTDOSEXE: sErrMsg = "DOS"
  106.                 Case GATERR_NOTWINEXE: sErrMsg = "Windows"
  107.                 Case GATERR_NOTVBEXE: sErrMsg = "Visual Basic application"
  108.     
  109.             End Select
  110.  
  111.             sErrMsg = "This file is not a " & sErrMsg & " executable."
  112.     
  113.         End If
  114.  
  115.         ' Display the error message.
  116.         MsgBox sErrMsg, MB_ICONEXCLAMATION
  117.  
  118.     End If
  119.  
  120. End Sub
  121.  
  122. Sub cmdBrowse_Click ()
  123.  
  124.     On Error Resume Next
  125.  
  126.     cmdOpen.Filename = "*.exe"
  127.     cmdOpen.Action = DLG_FILE_OPEN
  128.  
  129.     If Err = 0 Then
  130.         txtFileName = cmdOpen.Filename
  131.     End If
  132.  
  133. End Sub
  134.  
  135. Sub Form_Load ()
  136.  
  137.     ' Center the form.
  138.     Me.Left = (Screen.Width - Me.Width) / 2
  139.     Me.Top = (Screen.Height - Me.Height) / 2
  140.  
  141. End Sub
  142.  
  143. Sub txtFilename_Change ()
  144.  
  145.     cmdAppTitle.Enabled = Len(txtFileName) <> 0
  146.  
  147. End Sub
  148.  
  149.