Alexanbar » 22.05.2004 (Сб) 19:32
Этим способом Я считываю путь к WinRar (в качестве аргумента передаётся "rar":
[/code]
'WinRarApp = FindExebyFileExtension("rar")
Public Function FindExebyFileExtension _
(FileExtension As String) As String
Dim sType As String
Dim sName As String
Dim sFile As String
Dim iIndex As Integer
Dim lRegkey As Long
Dim iFoundCount As Integer
Dim nIcon As Integer
Dim lIcon As Long
Dim N As Long
sType = "." & LCase(FileExtension)
If RegOpenKey(HKEY_CLASSES_ROOT, ByVal sType, lRegkey) = 0 Then
sName = Space(255)
Call RegQueryValueEx(lRegkey, ByVal "", 0&, 1, ByVal sName, 255)
Call RegCloseKey(lRegkey)
If InStr(sName, Chr(0)) Then
sName = Left(sName, InStr(sName, Chr(0)) - 1)
Else
FindExebyFileExtension = ""
Exit Function
End If
If RegOpenKey(HKEY_CLASSES_ROOT, sName & "\shell\Open\command\", lRegkey) = 0 Then
sFile = Space(255)
RegQueryValueEx lRegkey, ByVal "", 0&, 1, ByVal sFile, 255
'MsgBox " sf " & sFile
Call RegCloseKey(lRegkey)
N = InStr(1, CStr(sFile), "exe", vbTextCompare)
If N > 0 Then
FindExebyFileExtension = Left(sFile, N + 2)
If Left(FindExebyFileExtension, 1) = Chr(34) Then
FindExebyFileExtension = Mid(FindExebyFileExtension, 2, Len(FindExebyFileExtension) - 1)
End If
Exit Function
Else
FindExebyFileExtension = ""
Exit Function
End If
End If
Else
FindExebyFileExtension = ""
End If
End Function