How can I get the path of an application installed in the machine from a VB6 application? For me, I need to get the path for WinZip.
A:
I don't know what your requirements or situation are, but usually when calling an external tool, the path and parameters are configurable. I.e., the program operator could configure the application to use WinRAR if they don't have WinZip installed.
If you already have a configuration mechanism set up, this should be very easy to implement, and far more flexible than hard-coding against a certain piece of software.
Jon Seigel
2010-05-17 13:47:35
A:
Read the registry key at this path:
HKEY_LOCAL_MACHINE\SOFTWARE\Nico Mak Computing\WinZip\Program\zip2exe
The path of that is the install path for WinZip
Cheeso
2010-05-17 13:48:14
+1
A:
I think you could do something like this by using the FindExecutable API function (create a file called test.zip in c:\temp first). This info taken from this link.
Const MAX_FILENAME_LEN = 260
Private Declare Function FindExecutable Lib "shell32.dll" Alias "FindExecutableA" (ByVal lpFile As String, _ ByVal lpDirectory As String, ByVal lpResult As String) As Long
Private Sub Form_Load()
Dim i As Integer, s2 As String
Const sFile = "C:\\temp\\test.zip"
'Check if the file exists
If Dir(sFile) = "" Or sFile = "" Then
MsgBox "File not found!", vbCritical
Exit Sub
End If
'Create a buffer
s2 = String(MAX_FILENAME_LEN, 32)
'Retrieve the name and handle of the executable, associated with this file
i = FindExecutable(sFile, vbNullString, s2)
If i > 32 Then
MsgBox Left$(s2, InStr(s2, Chr$(0)) - 1)
Else
MsgBox "No association found !"
End If
End Sub
dcp
2010-05-17 13:49:47