home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Visual Basic Programmer'…arterly (Limited Edition)
/
Visual_Basic_Programmers_Journal_VB-CD_Quarterly_Limited_Edition_1995.iso
/
code
/
ch29code
/
frmexist.frm
(
.txt
)
< prev
next >
Wrap
Visual Basic Form
|
1995-08-02
|
5KB
|
113 lines
VERSION 4.00
Begin VB.Form frmExists
AutoRedraw = -1 'True
BorderStyle = 3 'Fixed Dialog
Caption = "IsAppPresent Test"
ClientHeight = 1515
ClientLeft = 1095
ClientTop = 1515
ClientWidth = 2655
Height = 1920
Left = 1035
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 1515
ScaleWidth = 2655
Top = 1170
Width = 2775
Begin VB.CommandButton cmdExit
Caption = "&Exit"
Height = 375
Left = 90
TabIndex = 0
Top = 1125
Width = 2490
End
Attribute VB_Name = "frmExists"
Attribute VB_Creatable = False
Attribute VB_Exposed = False
'********************************************************************
' FRMEXISTS.FRM - Lists the existence of several Office apps.
'********************************************************************
Option Explicit
#If Win16 Then
Private Declare Function GetProfileString% Lib "Kernel" (ByVal _
sSection$, ByVal sKey$, ByVal sDef$, ByVal sRetStr$, _
ByVal iSize%)
#End If
'********************************************************************
' Checks to see if a file exists.
'********************************************************************
Function FileExists(sFileName$) As Boolean
On Error Resume Next
FileExists = IIf(Dir(Trim(sFileName)) <> "", True, False)
End Function
#If Win32 Then
'********************************************************************
' This function determines if a application is present by seeing
' if there is any text in the registry for the provided SubKey.
'********************************************************************
Public Function IsAppPresent(strSubKey$, strValueName$) As Boolean
IsAppPresent = CBool(Len(GetRegString(HKEY_CLASSES_ROOT, _
strSubKey, strValueName)))
End Function
#Else
'********************************************************************
' This function determines if a application is present.
' The sExtension arg is the 3 letter extension of its data files.
' The sDefaultPath is where you think the app might be installed.
'********************************************************************
Public Function IsAppPresent(sExtension$, sDefaultPath$) As Boolean
Dim sAppPath As String
'****************************************************************
' Check the [Extensions] section of the WIN.INI to see where
' the app is located. If the extension is not found, then
' the default EXE path (sDefaultPath) is checked.
'****************************************************************
sAppPath = Space(4098)
GetProfileString "Extensions", sExtension, sDefaultPath & " ^" _
& sExtension, sAppPath, Len(sAppPath)
'****************************************************************
' The [Extensions] section stores info in the following format:
' <extension>=<application path> ^<extension>
' To get the application path, you'll need to take everything
' to the left of the caret (^).
'****************************************************************
sAppPath = Left(sAppPath, InStr(sAppPath, "^") - 1)
'****************************************************************
' Return whether or not the application is present.
'****************************************************************
IsAppPresent = FileExists(sAppPath)
End Function
#End If
'********************************************************************
' Unloads the form.
'********************************************************************
Private Sub cmdExit_Click()
Unload Me
End Sub
'********************************************************************
' Performs some initialization steps, and list the existance of
' certain Office apps.
'********************************************************************
Private Sub Form_Load()
Move (Screen.Width - Width) / 2, (Screen.Height - Height) / 2
Print 'Print blank line
'****************************************************************
' Call the appropriate version of IsAppPresent, depending on
' the current platform.
'****************************************************************
#If Win32 Then
Print " Access", IsAppPresent("Access.Database\CurVer", "")
Print " Excel", IsAppPresent("Excel.Sheet\CurVer", "")
Print " PowerPoint", IsAppPresent("PowerPoint.Slide\CurVer", "")
Print " Word", IsAppPresent("Word.Document\CurVer", "")
#Else
Print " Access", IsAppPresent("mdb", "c:\access\msaccess.exe")
Print " Excel", IsAppPresent("xls", "c:\excel\excel.exe")
Print " PowerPoint", IsAppPresent("ppt", "c:\powerpnt\powerpnt.exe")
Print " Word", IsAppPresent("doc", "c:\winword\winword.exe")
#End If
End Sub