|
-
Jun 8th, 2002, 05:40 PM
#1
Thread Starter
Lively Member
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
-
Jun 8th, 2002, 05:45 PM
#2
-
Jun 8th, 2002, 05:51 PM
#3
Need-a-life Member
For example:
VB Code:
Option Explicit
Private Const HKEY_CLASSES_ROOT = &H80000000
Private Const WINAMP_REG_KEY = "WinAmp.File\shell\play\command"
Private Const KEY_QUERY_VALUE = &H1
Private Declare Function RegOpenKeyEx Lib "advapi32.dll" Alias "RegOpenKeyExA" _
(ByVal hKey As Long, ByVal lpSubKey As String, ByVal ulOptions As Long, _
ByVal samDesired As Long, phkResult As Long) As Long
Private Declare Function RegQueryValueEx Lib "advapi32.dll" Alias "RegQueryValueExA" _
(ByVal hKey As Long, ByVal lpValueName As String, ByVal lpReserved As Long, lpType As Long, _
lpData As Any, lpcbData As Long) As Long
Private Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) As Long
Public Function GetWinampPathAndExeFile() As String
'Finds the path of winamp
Dim WinampPath As String
WinampPath = RegGetString(HKEY_CLASSES_ROOT, WINAMP_REG_KEY, "")
If Len(WinampPath) < 8 Then GetWinampPathAndExeFile = "": Exit Function
WinampPath = Mid(WinampPath, 2, Len(WinampPath) - 7)
GetWinampPathAndExeFile = WinampPath
End Function
Public Function GetWinampPath() As String
Dim A As Integer
GetWinampPath = GetWinampPathAndExeFile
A = 1
Do While InStr(A + 1, GetWinampPath, "\")
A = A + 1
Loop
GetWinampPath = Left(GetWinampPath, A)
End Function
Public Function RegGetString$(hInKey As Long, ByVal subkey$, ByVal valname$)
Dim RetVal$, hSubKey As Long, dwType As Long, SZ As Long, v$, R As Long
RetVal$ = ""
R = RegOpenKeyEx(hInKey, subkey$, 0, KEY_QUERY_VALUE, hSubKey)
If R <> 0 Then Exit Function
SZ = 256
v$ = String$(SZ, 0)
R = RegQueryValueEx(hSubKey, valname$, 0, dwType, ByVal v$, SZ)
If R = 0 And dwType = 1 Then
RetVal$ = Left(v$, SZ - 1)
Else
RetVal$ = ""
End If
If hInKey = 0 Then R = RegCloseKey(hSubKey)
RegGetString$ = RetVal$
End Function
and then:
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|