在vb6中获取winzip的安装路径

在vb6中获取winzip的安装路径,vb6,Vb6,如何从VB6应用程序获取计算机中安装的应用程序的路径?对我来说,我需要获取WinZip的路径。我不知道您的需求或情况是什么,但通常在调用外部工具时,路径和参数是可配置的。也就是说,如果没有安装WinZip,程序操作员可以将应用程序配置为使用WinRAR 如果您已经设置了配置机制,那么这应该很容易实现,并且比针对某个软件的硬编码灵活得多。阅读以下路径中的注册表项: HKEY_LOCAL_MACHINE\SOFTWARE\Nico Mak Computing\WinZip\Program\zip2e

如何从VB6应用程序获取计算机中安装的应用程序的路径?对我来说,我需要获取WinZip的路径。

我不知道您的需求或情况是什么,但通常在调用外部工具时,路径和参数是可配置的。也就是说,如果没有安装WinZip,程序操作员可以将应用程序配置为使用WinRAR


如果您已经设置了配置机制,那么这应该很容易实现,并且比针对某个软件的硬编码灵活得多。

阅读以下路径中的注册表项:

HKEY_LOCAL_MACHINE\SOFTWARE\Nico Mak Computing\WinZip\Program\zip2exe

它的路径是WinZip的安装路径

我认为您可以通过使用FindExecutable API函数(首先在c:\temp中创建一个名为test.zip的文件)来完成类似的操作。此信息取自链接

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