Results 1 to 3 of 3

Thread: get appPath from registry

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Mar 2002
    Posts
    110

    get appPath from registry

    ok, i figure i need to use the GetSetting() function, but it doesn't seem to work right here is my code

    dim WinampPath

    WinampPath = GetSetting("Winamp", "Winamp", Default)

    it should return "c:/program files/winamp" but i get 0 instead.

    any help much appreciated

  2. #2
    Need-a-life Member Mc Brain's Avatar
    Join Date
    Apr 2000
    Location
    Buenos Aires, Argentina
    Posts
    6,808
    Winamp doesn't save its path in the "VB and VBA program settings" key. If you're trying to get the path where Winamp is installed, you will need to user APIs, GetSetting won't be of any use.
    Emiliano F. Martín


    If a post has helped you then please Rate it! (and give the user points he/she deserves by clicking on the image).
    Encourage the person who helped you to keep doing it, and give him the points he deserves.


    MP3 Organizer: Freeware to logically organize all your MP3s.

  3. #3
    Need-a-life Member Mc Brain's Avatar
    Join Date
    Apr 2000
    Location
    Buenos Aires, Argentina
    Posts
    6,808
    For example:
    VB Code:
    1. Option Explicit
    2.  
    3. Private Const HKEY_CLASSES_ROOT = &H80000000
    4. Private Const WINAMP_REG_KEY = "WinAmp.File\shell\play\command"
    5. Private Const KEY_QUERY_VALUE = &H1
    6.  
    7. Private Declare Function RegOpenKeyEx Lib "advapi32.dll" Alias "RegOpenKeyExA" _
    8.   (ByVal hKey As Long, ByVal lpSubKey As String, ByVal ulOptions As Long, _
    9.   ByVal samDesired As Long, phkResult As Long) As Long
    10. Private Declare Function RegQueryValueEx Lib "advapi32.dll" Alias "RegQueryValueExA" _
    11. (ByVal hKey As Long, ByVal lpValueName As String, ByVal lpReserved As Long, lpType As Long, _
    12. lpData As Any, lpcbData As Long) As Long
    13. Private Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) As Long
    14.  
    15. Public Function GetWinampPathAndExeFile() As String
    16. 'Finds the path of winamp
    17.    
    18.     Dim WinampPath As String
    19.    
    20.     WinampPath = RegGetString(HKEY_CLASSES_ROOT, WINAMP_REG_KEY, "")
    21.     If Len(WinampPath) < 8 Then GetWinampPathAndExeFile = "": Exit Function
    22.     WinampPath = Mid(WinampPath, 2, Len(WinampPath) - 7)
    23.     GetWinampPathAndExeFile = WinampPath
    24. End Function
    25.  
    26. Public Function GetWinampPath() As String
    27.     Dim A As Integer
    28.     GetWinampPath = GetWinampPathAndExeFile
    29.    
    30.     A = 1
    31.     Do While InStr(A + 1, GetWinampPath, "\")
    32.         A = A + 1
    33.     Loop
    34.     GetWinampPath = Left(GetWinampPath, A)
    35. End Function
    36.  
    37. Public Function RegGetString$(hInKey As Long, ByVal subkey$, ByVal valname$)
    38.     Dim RetVal$, hSubKey As Long, dwType As Long, SZ As Long, v$, R As Long
    39.     RetVal$ = ""
    40.     R = RegOpenKeyEx(hInKey, subkey$, 0, KEY_QUERY_VALUE, hSubKey)
    41.     If R <> 0 Then Exit Function
    42.     SZ = 256
    43.     v$ = String$(SZ, 0)
    44.     R = RegQueryValueEx(hSubKey, valname$, 0, dwType, ByVal v$, SZ)
    45.     If R = 0 And dwType = 1 Then
    46.         RetVal$ = Left(v$, SZ - 1)
    47.     Else
    48.         RetVal$ = ""
    49.     End If
    50.  
    51.  
    52.     If hInKey = 0 Then R = RegCloseKey(hSubKey)
    53.     RegGetString$ = RetVal$
    54. End Function
    and then:
    VB Code:
    1. MsgBox GetWinampPath
    Emiliano F. Martín


    If a post has helped you then please Rate it! (and give the user points he/she deserves by clicking on the image).
    Encourage the person who helped you to keep doing it, and give him the points he deserves.


    MP3 Organizer: Freeware to logically organize all your MP3s.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width