home *** CD-ROM | disk | FTP | other *** search
/ Programmer Plus 2007 / Programmer-Plus-2007.iso / Programming / Visual Basic new SourceCode and Projects / MP3 Player / frmAbout.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1999-12-11  |  9.0 KB  |  206 lines

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