• Lunes 29 de Abril de 2024, 21:59

Autor Tema:  Re: Comprobar si esta instalado un programa  (Leído 1608 veces)

pyonono

  • Nuevo Miembro
  • *
  • Mensajes: 2
    • Ver Perfil
Re: Comprobar si esta instalado un programa
« en: Martes 29 de Octubre de 2002, 12:19 »
0
Hola, me gustaría conocer qué código necesito para desde VB 6.0 comprobar si por ejemplo, en el ordenador donde voy a instalar mi aplicación, que sea el propio programa que verifique si está instalado el power point o cualquier otro, para instalarle o no, el visor correspondiente. Que tipo de verificacion hace eso?
Muchas Gracias.
Jose.

javierbalk

  • Miembro MUY activo
  • ***
  • Mensajes: 142
  • Nacionalidad: 00
    • Ver Perfil
    • Print preview y grabar PDF en Visual Basic 6
Comprobar si esta instalado un programa
« Respuesta #1 en: Jueves 31 de Octubre de 2002, 02:01 »
0
Hola:

Cada verificación sería diferente. Yo tengo un código que verifica si está Excel, sin duda modificándolo un poco se puede ver si están los otros componentes de Office, los otros programas hay que verlos de otra forma.

Coloca un CommandButton en un form y copia esto:

Private Sub Command1_Click()
    MsgBox IsAppPresent("Excel.SheetCurVer", "")
End Sub

Ahora Abre un Module y copia esto:

Option Explicit

Global Const gstrSEP_DIR$ = ""                         ' Carácter separador de directorios
Public Const gstrSEP_REGKEY$ = ""                      ' Carácter de separación de claves del Registro.
Global Const gstrSEP_DRIVE$ = ":"                       ' Carácter de separación de unidad, p.e., C:
Global Const gstrSEP_DIRALT$ = "/"                      ' Carácter alternativo de separación de directorio
Global Const gstrSEP_EXT$ = "."                         ' Carácter de separación de extensión de archivo
Public Const gstrSEP_PROGID = "."
Public Const gstrSEP_FILE$ = "|"                        ' Usa el carácter para delimitar listas de nombres de archivo ya que no es un carácter válido en un nombre de archivo.
Public Const gstrSEP_LIST = "|"

Global Const gstrCOLON$ = ":"

Private Declare Function RegOpenKey Lib "advapi32" Alias "RegOpenKeyA" (ByVal hKey As Long, ByVal lpSubKey As String, phkResult As Long) As Long
Private Declare Function RegQueryValueEx Lib "advapi32" Alias "RegQueryValueExA" (ByVal hKey As Long, ByVal lpValueName As String, lpReserved As Long, lptype As Long, lpData As Any, lpcbData As Long) As Long
Private Declare Function RegCloseKey& Lib "advapi32" (ByVal hKey&)

Private Const REG_SZ = 1
Private Const REG_EXPAND_SZ = 2
Private Const ERROR_SUCCESS = 0
Public Const HKEY_CLASSES_ROOT = &H80000000


Public Function IsAppPresent(strSubKey$, strValueName$) As Boolean
    IsAppPresent = CBool(Len(GetRegString(HKEY_CLASSES_ROOT, strSubKey, strValueName)))
End Function

Public Function GetRegString(hKey As Long, strSubKey As String, strValueName As String) As String
    Dim strSetting As String
    Dim lngDataLen As Long
    Dim lngRes As Long
   
    If RegOpenKey(hKey, strSubKey, lngRes) = ERROR_SUCCESS Then
        strSetting = Space(255)
        lngDataLen = Len(strSetting)
        If RegQueryValueEx(lngRes, strValueName, ByVal 0, REG_EXPAND_SZ, ByVal strSetting, lngDataLen) = ERROR_SUCCESS Then
            If lngDataLen > 1 Then
                GetRegString = Left(strSetting, lngDataLen - 1)
            End If
        End If
   
        If RegCloseKey(lngRes) <> ERROR_SUCCESS Then
           'MsgBox "RegCloseKey Failed: " & strSubKey, vbCritical
        End If
    End If
End Function

Saludos,

Javier