home *** CD-ROM | disk | FTP | other *** search
/ Planet Source Code Jumbo …e CD Visual Basic 1 to 7 / 1_2002.ISO / Data / Zips / CODE_UPLOAD1295812222000.psc / libprog / frmAbout.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  2000-10-19  |  9.3 KB  |  212 lines

  1. VERSION 5.00
  2. Begin VB.Form frmAbout 
  3.    BackColor       =   &H00FFFFFF&
  4.    BorderStyle     =   1  'Fixed Single
  5.    ClientHeight    =   3555
  6.    ClientLeft      =   2310
  7.    ClientTop       =   1620
  8.    ClientWidth     =   5730
  9.    ClipControls    =   0   'False
  10.    ControlBox      =   0   'False
  11.    LinkTopic       =   "Form2"
  12.    MaxButton       =   0   'False
  13.    MinButton       =   0   'False
  14.    ScaleHeight     =   2453.724
  15.    ScaleMode       =   0  'User
  16.    ScaleWidth      =   5380.766
  17.    Begin VB.CommandButton cmdOK 
  18.       Cancel          =   -1  'True
  19.       Caption         =   "OK"
  20.       Default         =   -1  'True
  21.       Height          =   345
  22.       Left            =   4245
  23.       TabIndex        =   0
  24.       Top             =   2625
  25.       Width           =   1260
  26.    End
  27.    Begin VB.CommandButton cmdSysInfo 
  28.       Caption         =   "&System Info..."
  29.       Height          =   345
  30.       Left            =   4260
  31.       TabIndex        =   1
  32.       Top             =   3075
  33.       Width           =   1245
  34.    End
  35.    Begin VB.Line Line1 
  36.       BorderColor     =   &H00808080&
  37.       BorderStyle     =   6  'Inside Solid
  38.       Index           =   1
  39.       X1              =   84.515
  40.       X2              =   5309.398
  41.       Y1              =   1687.583
  42.       Y2              =   1687.583
  43.    End
  44.    Begin VB.Label lblDescription 
  45.       BackStyle       =   0  'Transparent
  46.       Caption         =   $"frmAbout.frx":0000
  47.       ForeColor       =   &H00000000&
  48.       Height          =   1170
  49.       Left            =   1080
  50.       TabIndex        =   2
  51.       Top             =   1125
  52.       Width           =   3885
  53.    End
  54.    Begin VB.Label lblTitle 
  55.       BackStyle       =   0  'Transparent
  56.       Caption         =   "Application Title"
  57.       BeginProperty Font 
  58.          Name            =   "Coronet"
  59.          Size            =   21.75
  60.          Charset         =   0
  61.          Weight          =   700
  62.          Underline       =   0   'False
  63.          Italic          =   -1  'True
  64.          Strikethrough   =   0   'False
  65.       EndProperty
  66.       ForeColor       =   &H00000000&
  67.       Height          =   600
  68.       Left            =   1080
  69.       TabIndex        =   3
  70.       Top             =   120
  71.       Width           =   3885
  72.    End
  73.    Begin VB.Line Line1 
  74.       BorderColor     =   &H00FFFFFF&
  75.       BorderWidth     =   2
  76.       Index           =   0
  77.       X1              =   98.6
  78.       X2              =   5309.398
  79.       Y1              =   1697.936
  80.       Y2              =   1697.936
  81.    End
  82.    Begin VB.Label lblVersion 
  83.       BackStyle       =   0  'Transparent
  84.       Caption         =   "Version"
  85.       Height          =   225
  86.       Left            =   1050
  87.       TabIndex        =   4
  88.       Top             =   780
  89.       Width           =   3885
  90.    End
  91.    Begin VB.Image Image1 
  92.       Height          =   1755
  93.       Left            =   120
  94.       Picture         =   "frmAbout.frx":00AB
  95.       Stretch         =   -1  'True
  96.       Top             =   120
  97.       Width           =   1740
  98.    End
  99. Attribute VB_Name = "frmAbout"
  100. Attribute VB_GlobalNameSpace = False
  101. Attribute VB_Creatable = False
  102. Attribute VB_PredeclaredId = True
  103. Attribute VB_Exposed = False
  104. Option Explicit
  105. ' Reg Key Security Options...
  106. Const READ_CONTROL = &H20000
  107. Const KEY_QUERY_VALUE = &H1
  108. Const KEY_SET_VALUE = &H2
  109. Const KEY_CREATE_SUB_KEY = &H4
  110. Const KEY_ENUMERATE_SUB_KEYS = &H8
  111. Const KEY_NOTIFY = &H10
  112. Const KEY_CREATE_LINK = &H20
  113. Const KEY_ALL_ACCESS = KEY_QUERY_VALUE + KEY_SET_VALUE + _
  114.                        KEY_CREATE_SUB_KEY + KEY_ENUMERATE_SUB_KEYS + _
  115.                        KEY_NOTIFY + KEY_CREATE_LINK + READ_CONTROL
  116.                      
  117. ' Reg Key ROOT Types...
  118. Const HKEY_LOCAL_MACHINE = &H80000002
  119. Const ERROR_SUCCESS = 0
  120. Const REG_SZ = 1                         ' Unicode nul terminated string
  121. Const REG_DWORD = 4                      ' 32-bit number
  122. Const gREGKEYSYSINFOLOC = "SOFTWARE\Microsoft\Shared Tools Location"
  123. Const gREGVALSYSINFOLOC = "MSINFO"
  124. Const gREGKEYSYSINFO = "SOFTWARE\Microsoft\Shared Tools\MSINFO"
  125. Const gREGVALSYSINFO = "PATH"
  126. Private Declare Function RegOpenKeyEx Lib "advapi32" Alias "RegOpenKeyExA" (ByVal hKey As Long, ByVal lpSubKey As String, ByVal ulOptions As Long, ByVal samDesired As Long, ByRef phkResult As Long) As Long
  127. Private Declare Function RegQueryValueEx Lib "advapi32" Alias "RegQueryValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal lpReserved As Long, ByRef lpType As Long, ByVal lpData As String, ByRef lpcbData As Long) As Long
  128. Private Declare Function RegCloseKey Lib "advapi32" (ByVal hKey As Long) As Long
  129. Private Sub cmdSysInfo_Click()
  130.   Call StartSysInfo
  131. End Sub
  132. Private Sub cmdOK_Click()
  133.   Unload Me
  134. End Sub
  135. Private Sub Form_Load()
  136.     Me.Caption = "About " & App.Title
  137.     lblVersion.Caption = "Beta 1.0" '"Version " & App.Major & "." & App.Minor & "." & App.Revision
  138.     lblTitle.Caption = App.Title
  139. End Sub
  140. Public Sub StartSysInfo()
  141.     On Error GoTo SysInfoErr
  142.     Dim rc As Long
  143.     Dim SysInfoPath As String
  144.     ' Try To Get System Info Program Path\Name From Registry...
  145.     If GetKeyValue(HKEY_LOCAL_MACHINE, gREGKEYSYSINFO, gREGVALSYSINFO, SysInfoPath) Then
  146.     ' Try To Get System Info Program Path Only From Registry...
  147.     ElseIf GetKeyValue(HKEY_LOCAL_MACHINE, gREGKEYSYSINFOLOC, gREGVALSYSINFOLOC, SysInfoPath) Then
  148.         ' Validate Existance Of Known 32 Bit File Version
  149.         If (Dir(SysInfoPath & "\MSINFO32.EXE") <> "") Then
  150.             SysInfoPath = SysInfoPath & "\MSINFO32.EXE"
  151.             
  152.         ' Error - File Can Not Be Found...
  153.         Else
  154.             GoTo SysInfoErr
  155.         End If
  156.     ' Error - Registry Entry Can Not Be Found...
  157.     Else
  158.         GoTo SysInfoErr
  159.     End If
  160.     Call Shell(SysInfoPath, vbNormalFocus)
  161.     Exit Sub
  162. SysInfoErr:
  163.     MsgBox "System Information Is Unavailable At This Time", vbOKOnly
  164. End Sub
  165. Public Function GetKeyValue(KeyRoot As Long, KeyName As String, SubKeyRef As String, ByRef KeyVal As String) As Boolean
  166.     Dim i As Long                                           ' Loop Counter
  167.     Dim rc As Long                                          ' Return Code
  168.     Dim hKey As Long                                        ' Handle To An Open Registry Key
  169.     Dim hDepth As Long                                      '
  170.     Dim KeyValType As Long                                  ' Data Type Of A Registry Key
  171.     Dim tmpVal As String                                    ' Tempory Storage For A Registry Key Value
  172.     Dim KeyValSize As Long                                  ' Size Of Registry Key Variable
  173.     '------------------------------------------------------------
  174.     ' Open RegKey Under KeyRoot {HKEY_LOCAL_MACHINE...}
  175.     '------------------------------------------------------------
  176.     rc = RegOpenKeyEx(KeyRoot, KeyName, 0, KEY_ALL_ACCESS, hKey) ' Open Registry Key
  177.     If (rc <> ERROR_SUCCESS) Then GoTo GetKeyError          ' Handle Error...
  178.     tmpVal = String$(1024, 0)                             ' Allocate Variable Space
  179.     KeyValSize = 1024                                       ' Mark Variable Size
  180.     '------------------------------------------------------------
  181.     ' Retrieve Registry Key Value...
  182.     '------------------------------------------------------------
  183.     rc = RegQueryValueEx(hKey, SubKeyRef, 0, _
  184.                          KeyValType, tmpVal, KeyValSize)    ' Get/Create Key Value
  185.                         
  186.     If (rc <> ERROR_SUCCESS) Then GoTo GetKeyError          ' Handle Errors
  187.     If (Asc(Mid(tmpVal, KeyValSize, 1)) = 0) Then           ' Win95 Adds Null Terminated String...
  188.         tmpVal = Left(tmpVal, KeyValSize - 1)               ' Null Found, Extract From String
  189.     Else                                                    ' WinNT Does NOT Null Terminate String...
  190.         tmpVal = Left(tmpVal, KeyValSize)                   ' Null Not Found, Extract String Only
  191.     End If
  192.     '------------------------------------------------------------
  193.     ' Determine Key Value Type For Conversion...
  194.     '------------------------------------------------------------
  195.     Select Case KeyValType                                  ' Search Data Types...
  196.     Case REG_SZ                                             ' String Registry Key Data Type
  197.         KeyVal = tmpVal                                     ' Copy String Value
  198.     Case REG_DWORD                                          ' Double Word Registry Key Data Type
  199.         For i = Len(tmpVal) To 1 Step -1                    ' Convert Each Bit
  200.             KeyVal = KeyVal + Hex(Asc(Mid(tmpVal, i, 1)))   ' Build Value Char. By Char.
  201.         Next
  202.         KeyVal = Format$("&h" + KeyVal)                     ' Convert Double Word To String
  203.     End Select
  204.     GetKeyValue = True                                      ' Return Success
  205.     rc = RegCloseKey(hKey)                                  ' Close Registry Key
  206.     Exit Function                                           ' Exit
  207. GetKeyError:      ' Cleanup After An Error Has Occured...
  208.     KeyVal = ""                                             ' Set Return Val To Empty String
  209.     GetKeyValue = False                                     ' Return Failure
  210.     rc = RegCloseKey(hKey)                                  ' Close Registry Key
  211. End Function
  212.