|
-
Apr 11th, 2000, 05:04 PM
#1
Thread Starter
transcendental analytic
OKej, Is that clear enought? There have to be some way of getting the filename out of winamp. Ive posted this several times, but noone seems to have any clues. There was someone that had this idéa about copy memory, how do I use this?
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Apr 11th, 2000, 05:28 PM
#2
Member
A bit haphazard but stil...
I know this is probably a long way round, but it's all I can think of at the mo. If Winamp is set to display the song title in the taskbar icon, then you should be able to use the shell function to return the filename (i.e. whatever text appears after "Winamp" in the taskbar icon. Have you tried looking at Winamp.com's NSDN (NullSoft Developer Network) site? They've got quite a bit of documentation up there.
Hope this helps
Matt
-
Apr 11th, 2000, 10:04 PM
#3
If you want to get the current song, then you can try something like this:
Code:
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
Private Sub Command1_Click()
Dim lngRet As Long
Dim strSong As String
Dim lngHwnd As Long
lngHwnd = FindWindow("Winamp v1.x", vbNullString)
If lngHwnd <> 0 Then
strSong = Space(256)
lngRet = GetWindowText(lngHwnd, strSong, Len(strSong))
MsgBox strSong
End If
End Sub
-
Apr 11th, 2000, 10:59 PM
#4
Frenzied Member
Is that all you wanted to do kedaman!!
Thats easy, the rest of them are on the right track.
Code:
Case "TITLE"
NewCaption = Space(255)
retval = GetWindowText(WinamphWnd, NewCaption, 255)
NewCaption = Left$(NewCaption, retval)
textPos = InStr(NewCaption, ". ") + 1 '+1 because instr returns the location of the first char
NewCaption = Right$(NewCaption, Len(NewCaption) - textPos)
'Now trim the '- Winamp' from the caption
textPos = InStr(NewCaption, " - Winamp") '+1 because instr returns the location of the first char
If textPos > 0 Then 'Just in Case " - Winamp" doesnt appear in the caption
NewCaption = Left$(NewCaption, textPos - 1)
End If
'Now split the caption into Title and Artist
'We should have a caption that reads "Artist - Title"
If InStr(1, NewCaption, ".mp3", vbTextCompare) > 0 Then GetInfo = "ERROR"
textPos = InStr(NewCaption, " - ")
If textPos > 0 Then
GetInfo = Trim$(Right$(NewCaption, (Len(NewCaption) - textPos) - 1))
Else
GetInfo = ""
End If
Case "ARTIST"
NewCaption = Space(255)
retval = GetWindowText(WinamphWnd, NewCaption, 255)
NewCaption = Left$(NewCaption, retval)
textPos = InStr(NewCaption, ". ") + 1 '+1 because instr returns the location of the first char
NewCaption = Right$(NewCaption, Len(NewCaption) - textPos)
'Now trim the '- Winamp' from the caption
textPos = InStr(NewCaption, " - Winamp") '+1 because instr returns the location of the first char
If textPos > 0 Then 'Just in Case " - Winamp" doesnt appear in the caption
NewCaption = Left$(NewCaption, textPos - 1)
End If
'Now split the caption into Title and Artist
'We should have a caption that reads "Artist - Title"
If InStr(1, NewCaption, ".mp3", vbTextCompare) > 0 Then GetInfo = "ERROR"
textPos = InStr(NewCaption, " - ")
If textPos > 0 Then
GetInfo = Trim$(Left$(NewCaption, textPos - 1))
Else
GetInfo = Trim$(NewCaption)
End If
-
Apr 12th, 2000, 03:41 AM
#5
Thread Starter
transcendental analytic
ARGH! I'm not angry at you people, but on my self, I tried to be as clear as possible but this was not enough. I dont want the title, I dont want the artist, and if saying I want the filename, isn't clear, I should say I WANT THE PATH, I want something like "C:\MP3\ARTIST - SONG.MP3"
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Apr 12th, 2000, 04:00 AM
#6
Hyperactive Member
try reading through this, might help:
http://www.winamp.com/nsdn/plugindev/speaking.jhtml
"211 Retrieves (and returns a pointer in 'ret') a string that contains the filename of a playlist entry (indexed by 'data'). Returns NULL if error, or if 'data' is out of range"
"People who think they know everything are a great annoyance to those of us who do."
-
Apr 12th, 2000, 04:41 AM
#7
Thread Starter
transcendental analytic
Try this out and try that out, thats what i tried out in my first thread, noone, im not angry at you, but I really shoud tell you that I have to do a plugin to get that pointer(Thats not what im doing) or do you have another way getting the pointer?
The old thread
[Edited by kedaman on 04-13-2000 at 12:53 AM]
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Apr 12th, 2000, 05:33 AM
#8
Addicted Member
Poor, poor kedaman!
I've been watching your threads on this topic for some time now, waiting to see if anyone would give you a solution. But, alas, no one has been able to give you want you really want! As an aspiring Winamp developer (meaning I want to get into it, I just need to find the time to finish my programs) I think I can lend you a hand.
First of all, I need to ask if you've read through the NSDN documentation? Everything you need is right there, you just need to read in to it a little bit.
If you've tried this and you're still stuck, a quick and painless solution is to send the WM_USER message with 120 in the lParam. This will write out the entire contents of the current Winamp playlist to the default Winamp Play List (located in the Winamp directory in the Winamp.m3u file) and return the current position in the playlist. You can then open up that file and deal with the data in there. The first line is always (as far as I've seen) "#EXTM3U", after this there is a special line for every entry that is currently displayed in the Winamp Play List. These lines always start with "#EXTINF:". The rest of the lines are the full paths to the files in the list. Therefore all you need to do is read the m3u into a string and strip out the above mentioned useless lines (for your needs at least), now you'll have a list of all of the paths to the files. All that's left to do is to read down the list until you get to the entry that was originally returned by the SendMessage call, remembering that this value is zero based (if it returned 3 then the 4th line in the file would be the current file).
Ther you go! I know it's not the best method of doing this, but you seem SO desperate, I just needed to give you something to work with! I AM working on a better method at the moment, but at least this will give you something for the time being.
FYI, I'm currently developing a Winamp Class with most of the basic functionality and definitions built in, if your interested I'll post it when I'm done.
Also, did you know that the Tag Info is stored at the end of a mp3 file? Just search for the keyword TAG. Very useful tidbit if you didn't know already!
Later.
-
Apr 12th, 2000, 03:29 PM
#9
Thread Starter
transcendental analytic
OH, god! Thanks SonGouki, You saved my day! I had thoughts about this m3ulist, but why did my brain say something like this: "It will only show the Artist and Title" I must have mixed it up with Generate Html playlist. That what I call painful stupidity. Yes I have readed the NSDN very carefully, especially the speaking winamp. I know, the playlist-method will cost some performance, (or not if I use it only when winamp changes song) and it's somewhat indirect, what if someone already have put a winamp.m3u in the winampdir, will it overwrite or what? Ok, I have a solution for that, but I still want a direct way for doing this, so SonGouki, could you notify me when you have come up with the better method?
I know, the tag Is stored inte end of the file, In fact I know it really well, cuz my project has to do with it. Im creating a prog that scrolls songtext and stores the songtextdata within the mp3, between the TAG and the mp3.
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Apr 12th, 2000, 06:12 PM
#10
Thread Starter
transcendental analytic
Finally! And it works fast too! 3 milliseconds
Code:
Function GetFilename() As String '3ms
Dim plspos As Integer, playlistloc As String, crap As String, fileloc As String, n As Integer
plpos = SendMessage(WinamphWnd, WM_USER, 1, 120)
playlistloc = GetExeFromHandle(CLng(WinamphWnd)): playlistloc = Left(playlistloc, LInStr(playlistloc, "\")) & "Winamp.m3u"
If Len(Dir(playlistloc)) Then
Open playlistloc For Input As #1
Input #1, crap
For n = 0 To plpos
If EOF(1) Then Exit For Else Input #1, crap
If EOF(1) Then Exit For Else Input #1, crap
If EOF(1) Then Exit For Else Input #1, fileloc
Next n
Close #1
Else
' The W2k way
End If
GetFilename = fileloc
End Function
But this wont work under W2k, how do I get the path to winamp another way?
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Apr 12th, 2000, 08:01 PM
#11
Addicted Member
Happy to help you out!
For the Winamp path you need to read the registry. I've found the path, in every machine I've looked at with Winamp at least, in the Key:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\Winamp.exe
This Key contains both the path to the Winamp executable and the Winamp directory.
Now maybe you can help me with a non-related problem (or you can tell me someone who can). I've been looking for help on this problem for as long as you have on this Winamp thing. I REALLY need to find out how to list all of an Exe's DLL dependencies. There is a small program that ships with VB called Depends, I need to basically duplicate its functionality. If you know, or know somebody that knows, how to do this or has the source code to this I would really appreciate. It's driving me nuts tryinig to figure it out!!
Thanks either way though.
Later.
[Edited by SonGouki on 04-13-2000 at 09:02 AM]
-
Apr 13th, 2000, 03:20 AM
#12
Thread Starter
transcendental analytic
I know, but I don't know how to get that from the registry, in fact, there's a lot of keys with the winamp path, but only know Getsetting and it seems like I can't get it using that. Could you help me with that?
Also, I don't know about any prog called Depends, or nothing like it, so I can't help you with that. I guess it's as hard as this (or harder) cuz you haven't find any solution yet. Good luck anyway!
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Apr 13th, 2000, 07:07 AM
#13
Addicted Member
Well, kedaman, just because I know how much time you've spent on this already, I'll give you a bunch of registry code that is already commented to make it easier for you to understand (or not). Be aware that it is in MY own coding standard, sorry, but it was too much to convert it to the standard style AND check it's validity, so I just left it in the style that I've already tested. Okay here goes...
First, all of the Declarations:
Code:
'<<< CONSTANTS >>>
'Defined variable maximum sizes.
Private Const MAX_PATH As Integer = 260
Private Const MAXBYTE As Integer = &HFF
Private Const MAXCHAR As Integer = &H7F
Private Const MAXSHORT As Integer = &H7FFF
'Error codes.
Private Const ERROR_SUCCESS As Long = 0
Private Const ERROR_MORE_DATA As Long = 234
'Top-level registry Keys.
Private Const HKEY_CLASSES_ROOT As Long = &H80000000
Private Const HKEY_CURRENT_USER As Long = &H80000001
Private Const HKEY_LOCAL_MACHINE As Long = &H80000002
Private Const HKEY_USERS As Long = &H80000003
Private Const HKEY_PERFORMANCE_DATA As Long = &H80000004
Private Const HKEY_CURRENT_CONFIG As Long = &H80000005
Private Const HKEY_DYN_DATA As Long = &H80000006
'Registry data types.
Private Const REG_NONE As Integer = 0
Private Const REG_SZ As Integer = 1
Private Const REG_EXPAND_SZ As Integer = 2
Private Const REG_BINARY As Integer = 3
Private Const REG_DWORD As Integer = 4
Private Const REG_DWORD_LITTLE_ENDIAN As Integer = 4
Private Const REG_DWORD_BIG_ENDIAN As Integer = 5
Private Const REG_LINK As Integer = 6
Private Const REG_MULTI_SZ As Integer = 7
Private Const REG_RESOURCE_LIST As Integer = 8
Private Const REG_FULL_RESOURCE_DESCRIPTOR As Integer = 9
Private Const REG_RESOURCE_REQUIREMENTS_LIST As Integer = 10
'Object security constants.
Private Const READ_CONTROL As Long = &H20000
Private Const SYNCHRONIZE As Long = &H100000
Private Const SPECIFIC_RIGHTS_ALL As Long = &HFFFF
Private Const STANDARD_RIGHTS_REQUIRED As Long = &HF0000
Private Const STANDARD_RIGHTS_ALL As Long = &H1F0000
Private Const STANDARD_RIGHTS_READ As Long = (READ_CONTROL)
Private Const STANDARD_RIGHTS_WRITE As Long = (READ_CONTROL)
'Registry Key operation request flags.
Private Const KEY_EVENT As Long = &H1
Private Const KEY_QUERY_VALUE As Long = &H1
Private Const KEY_SET_VALUE As Long = &H2
Private Const KEY_CREATE_SUB_KEY As Long = &H4
Private Const KEY_ENUMERATE_SUB_KEYS As Long = &H8
Private Const KEY_NOTIFY As Long = &H10
Private Const KEY_CREATE_LINK As Long = &H20
Private Const KEY_READ As Long = ((STANDARD_RIGHTS_READ Or KEY_QUERY_VALUE _
Or KEY_ENUMERATE_SUB_KEYS Or KEY_NOTIFY) And (Not SYNCHRONIZE))
Private Const KEY_WRITE As Long = ((STANDARD_RIGHTS_WRITE Or KEY_SET_VALUE _
Or KEY_CREATE_SUB_KEY) And (Not SYNCHRONIZE))
Private Const KEY_EXECUTE As Long = ((KEY_READ) And (Not SYNCHRONIZE))
Private Const KEY_ALL_ACCESS As Long = ((STANDARD_RIGHTS_ALL Or KEY_QUERY_VALUE _
Or KEY_SET_VALUE Or KEY_CREATE_SUB_KEY _
Or KEY_ENUMERATE_SUB_KEYS Or KEY_NOTIFY _
Or KEY_CREATE_LINK) And (Not SYNCHRONIZE))
'<<< TYPE DEFINITIONS >>>
Private Type FILETIME
dwLowDateTime As Long
dwHighDateTime As Long
End Type
'<<< DECLARES >>>
'---------------------------------------------------------------------------------------------------
' Name (Private Function):
' - apiRegCloseKey
' Purpose:
' - Closes a handle to a Key in the system registry.
' Parameters:
' ByVal hKey As Long
' - The Key to close.
' Returns:
' As Long
' - Zero on success, all other values indicate an error code.
'---------------------------------------------------------------------------------------------------
Private Declare Function apiRegCloseKey _
Lib "advapi32.dll" _
Alias "RegCloseKey" _
(ByVal hKey As Long) As Long
'---------------------------------------------------------------------------------------------------
' Name (Private Function):
' - apiRegEnumValue
' Purpose:
' - Enumerates all of the Values within a Registry SubKey.
' Parameters:
' ByVal hKey As Long
' - A handle of an open Key or one of the standard Key names.
' ByVal dwIndex As Long
' - The current Value to enumerate, zero-based.
' ByVal lpValueName As String
' - The Name of the Value in the SubKey.
' lpcbValueName As Long
' - Pass the size of lpValueName.
' - Returns the number of characters loaded into lpValueName.
' ByVal lpReserved As Long
' - Not used, set to zero.
' lpType As Long
' - The Registry data-type of the Value.
' lpData As Byte
' - The Data of the Value in the SubKey.
' lpcbData As Long
' - Pass the size of lpData.
' - Returns the number of characters loaded into lpData.
' Returns:
' As Long
' - Zero on success, all other values indicate an error code.
'---------------------------------------------------------------------------------------------------
Private Declare Function apiRegEnumValue _
Lib "advapi32.dll" _
Alias "RegEnumValueA" _
(ByVal hKey As Long, ByVal dwIndex As Long, _
ByVal lpValueName As String, lpcbValueName As Long, _
ByVal lpReserved As Long, lpType As Long, lpData As Byte, _
lpcbData As Long) As Long
'---------------------------------------------------------------------------------------------------
' Name (Private Function):
' - apiRegOpenKeyEx
' Purpose:
' - Opens an existing Key.
' Parameters:
' ByVal hKey As Long
' - A handle of an open Key or one of the standard Key names.
' ByVal lpSubKey As String
' - Name of the Key to open.
' ByVal ulOptions As Long
' - Not used, set to zero.
' ByVal samDesired As Long
' - One or more constants with the KEY_ prefix combined to describe which operations
' are allowed for this Key.
' phkResult As Long
' - A variable to load with a handle to the open Key.
' Returns:
' As Long
' - Zero on success, all other values indicate an error code.
'---------------------------------------------------------------------------------------------------
Private Declare Function apiRegOpenKeyEx _
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
'---------------------------------------------------------------------------------------------------
' Name (Private Function):
' - apiRegQueryInfoKey
' Purpose:
' - Retrieves information about a Registry Key.
' Parameters:
' ByVal hKey As Long
' - A handle of an open Key or one of the standard Key names.
' ByVal lpClass As String
' - The Class name of the Key.
' lpcbClass As Long
' - Pass the size of lpClass.
' - Returns the number of characters loaded into lpClass.
' ByVal lpReserved As Long
' - Not used, set to zero.
' lpcSubKeys As Long
' - The number of SubKeys stored in this Key.
' lpcbMaxSubKeyLen As Long
' - The longest SubKey name stored in this Key.
' lpcbMaxClassLen As Long
' - The longest Class name stored in this Key.
' lpcValues As Long
' - The number of Values stored in this Key.
' lpcbMaxValueNameLen As Long
' - The longest Value name stored in this Key.
' lpcbMaxValueLen As Long
' - The longest Value Data buffer in this Key.
' lpcbSecurityDescriptor As Long
' - The length of this Key's Security Descriptor.
' lpftLastWriteTime As FILETIME
' - The last modification time of this Key.
' Returns:
' As Long
' - Zero on success, all other values indicate an error code.
'---------------------------------------------------------------------------------------------------
Private Declare Function apiRegQueryInfoKey _
Lib "advapi32.dll" _
Alias "RegQueryInfoKeyA" _
(ByVal hKey As Long, ByVal lpClass As String, _
lpcbClass As Long, ByVal lpReserved As Long, _
lpcSubKeys As Long, lpcbMaxSubKeyLen As Long, _
lpcbMaxClassLen As Long, lpcValues As Long, _
lpcbMaxValueNameLen As Long, lpcbMaxValueLen As Long, _
lpcbSecurityDescriptor As Long, lpftLastWriteTime As FILETIME) As Long
'---------------------------------------------------------------------------------------------------
' Name (Private Function):
' - apiRegQueryValueEx
' Purpose:
' - Retrieves a Value for a Key.
' Parameters:
' ByVal hKey As Long
' - A handle of an open Key or one of the standard Key names.
' ByVal lpValueName As String
' - The name of the Value to retrieve.
' ByVal lpReserved As Long
' - Not used, set to zero.
' lpType As Long
' - A variable to load with the type of data retrieved.
' lpData As Any
' - A buffer to load with the Value specified.
' - Pass ByVal if a string is passed.
' lpcbData As Long
' - Pass the size of lpData.
' - Returns the number bytes loaded into lpData.
' Returns:
' As Long
' - Zero on success, all other values indicate an error code.
'---------------------------------------------------------------------------------------------------
Private Declare Function apiRegQueryValueEx _
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
These will give you almost all of the constants you will need to deal with the registry, and a few of the more useful APIs.
Anyway, here are a few examples of using these functions:
To retrieve a string from the Registry
eg. The Winamp directory.
Code:
Private Sub Form_Load()
Dim sDir As String
Call mbGetRegValueData(HKEY_LOCAL_MACHINE, _
"SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\Winamp.exe", _
"Path", sDir)
Call MsgBox(sDir)
End Sub
'---------------------------------------------------------------------------------------------------
' Name (Private Function):
' - mbGetRegValueData
' Purpose:
' - Retrieves SubKey Value Data string from the Registry.
' Parameters:
' ByVal vlKey As Long
' - An open Registry Key or one of the pre-defined Keys.
' ByVal vsSubKey As String
' - Path to the SubKey to look in.
' ByVal vsValueName As String
' - The name of the Value to retrieve.
' - Send vbNullString for the Default Value of the SubKey.
' ByRef rsValueData As String
' - Returns the Value Data from the entry.
' Assumes:
' - The base functionality of the Registry is intact, and that the location of the
' fundamental SubKeys are in the correct locations.
' Returns:
' As Boolean
' - True on success, False on failure.
'---------------------------------------------------------------------------------------------------
Private Function mbGetRegValueData( _
ByVal vlKey As Long, _
ByVal vsSubKey As String, _
ByVal vsValueName As String, _
ByRef rsValueData As String) As Boolean
Dim bRetrievalSuccess As Boolean 'Success of function.
Dim lReturnVal As Long 'API return value.
Dim hRegKey As Long 'Handle to the opened Registry Key.
Dim lDataType As Long 'The data type of the Registry Value's Data.
Dim lDataSize As Long 'The length of sData, the Registry Value's Data.
Dim sData As String 'The Data of the Registry Value.
lReturnVal = apiRegOpenKeyEx(vlKey, vsSubKey, 0, KEY_QUERY_VALUE, hRegKey)
If lReturnVal = ERROR_SUCCESS Then
sData = String$(MAXBYTE, 0)
lDataSize = MAXBYTE
lReturnVal = apiRegQueryValueEx(hRegKey, vsValueName, 0, lDataType, ByVal sData, lDataSize)
'Ensure the validity of the Data returned.
If lReturnVal = ERROR_SUCCESS _
And lDataType = REG_SZ _
And lDataSize > 0 Then
sData = Left(sData, lDataSize - 1)
bRetrievalSuccess = True
Else
sData = vbNullString
bRetrievalSuccess = False
End If
'Ensure that handle is resolved when it is no longer needed.
lReturnVal = apiRegCloseKey(hRegKey)
If lReturnVal <> ERROR_SUCCESS Then
bRetrievalSuccess = False
End If
End If
rsValueData = sData
mbGetRegValueData = bRetrievalSuccess
End Function
To retrieve all of the Values from a Registry SubKey
Code:
Private Sub Form_Load()
Dim asVNames() As String
Dim asVData() As String
Call miListRegValues(HKEY_LOCAL_MACHINE, _
"SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\Winamp.exe", _
asVNames, asVData)
Call MsgBox(asVNames(0) & " = " & asVData(0) & vbCrLf & _
asVNames(1) & " = " & asVData(1))
End Sub
'---------------------------------------------------------------------------------------------------
' Name (Private Function):
' - miListRegValues
' Purpose:
' - Retrieves all of the SubKey Value Names and their corresponding Data strings
' from the Registry.
' Parameters:
' ByVal vlKey As Long
' - An open Registry Key or one of the pre-defined Keys.
' ByVal vsSubKey As String
' - Path to the SubKey to look in.
' ByRef rasValueNames() As String
' - Returns all of the Value Names in the specified Key.
' ByRef rasValueData() As String
' - Returns all of the corresponding Value Data in the specified Key.
' Assumes:
' - The base functionality of the Registry is intact, and that the location of the
' fundamental SubKeys are in the correct locations.
' Returns:
' As Boolean
' - The number of Values in the specified Key.
' - Returns -1 if there is an error.
'---------------------------------------------------------------------------------------------------
Private Function miListRegValues( _
ByVal vhKey As Long, _
ByVal vsSubKey As String, _
ByRef rasValueNames() As String, _
ByRef rasValueData() As String) As Integer
Dim bytValueData() As Byte
Dim idx As Integer
Dim iMatches As Integer
Dim lReturnVal As Long
Dim hRegKey As Long
Dim lClass As Long
Dim lNumSubKeys As Long
Dim lMaxSubKeyLen As Long
Dim lMaxClassLen As Long
Dim lNumValues As Long
Dim lMaxValueNameLen As Long
Dim lMaxValueDataLen As Long
Dim lSecurityDescriptorLen As Long
Dim lNameLen As Long
Dim lDataLen As Long
Dim lDataType As Long
Dim sClass As String
Dim sValueName As String
Dim udtModificationTime As FILETIME
lReturnVal = apiRegOpenKeyEx(vhKey, vsSubKey, 0, KEY_READ, hRegKey)
If lReturnVal = ERROR_SUCCESS Then
sClass = String(MAX_PATH, 0)
lClass = Len(sClass) - 1
lReturnVal = apiRegQueryInfoKey(hRegKey, sClass, lClass, 0, lNumSubKeys, lMaxSubKeyLen, _
lMaxClassLen, lNumValues, lMaxValueNameLen, lMaxValueDataLen, _
lSecurityDescriptorLen, udtModificationTime)
If lReturnVal = ERROR_SUCCESS Then
Erase rasValueNames
Erase rasValueData
ReDim bytValueData(lMaxValueDataLen + 1)
For idx = 0 To lNumValues - 1 Step 1
lNameLen = lMaxValueNameLen + 1
sValueName = String(lNameLen, 0)
lDataLen = lMaxValueDataLen + 1
lReturnVal = apiRegEnumValue(hRegKey, idx, sValueName, lNameLen, 0, _
lDataType, bytValueData(0), lDataLen)
'Only lists strings, more functionality needed to deal with
'the other Registry data-types.
If lReturnVal = ERROR_SUCCESS _
And lDataType = REG_SZ Then
If lDataLen > 0 Then
lDataLen = lDataLen - 1
End If
ReDim Preserve rasValueNames(iMatches)
ReDim Preserve rasValueData(iMatches)
rasValueNames(iMatches) = Left(sValueName, lNameLen)
rasValueData(iMatches) = Left(StrConv(bytValueData, vbUnicode), lDataLen)
iMatches = iMatches + 1
End If
Next idx
End If
Call apiRegCloseKey(hRegKey)
End If
miListRegValues = iMatches - 1
End Function
Those are a couple of the most used API functions for accessing the Registry. Keep in mind, however, that the Registry contains many different kinds of data-types (listed in my declartions section in the first code segment) and that special kinds of handling must be incorporated to deal with these types. For example, there is one data type called Multi SZ, these are a single string of data that contain many strings within it. Each sub-string is separated by a NULL character and the entire string is ended with two NULL characters. Here is an example of how to deal with these strings:
Parsing Multi SZ strings
Code:
'---------------------------------------------------------------------------------------------------
' Name (Private Function):
' - miParseMultiSZ
' Purpose:
' - Parses a Multi SZ string buffer, which is a set of strings separated by NULL characters
' and terminated by two NULL characters, into an array of strings.
' Parameters:
' ByVal vsMultiSZ As String
' - The Mulit SZ string to perform the parse on.
' ByVal vlSize As Long
' - The size of vsMultiSZ.
' ByRef rasValues() As String
' - An array to load with all of the seperate strings in vsMultiSZ.
' Assumes:
' - The string passed in, vsMultiSZ, is in fact a Multi SZ string.
' Returns:
' As Integer
' - The number of strings in the Multi SZ string.
'---------------------------------------------------------------------------------------------------
Private Function miParseMultiSZ( _
ByVal vsMultiSZ As String, ByVal vlSize As Long, _
ByRef rasValues() As String) As Integer
Dim iArraySize As Integer 'The size of the array to return.
vsMultiSZ = Left(vsMultiSZ, vlSize)
Erase rasValues
rasValues = Split(vsMultiSZ, vbNullChar, , vbBinaryCompare)
'Necessary to delete last entry in array because a Multi SZ string is terminated by
'two NULL characters, and the split will return an extra element for the last NULL.
If rasValues(UBound(rasValues)) = vbNullString Then
iArraySize = UBound(rasValues) - 1
ReDim Preserve rasValues(0 To iArraySize)
Else
iArraySize = UBound(rasValues)
End If
miParseMultiSZ = iArraySize
End Function
There you go! I hope this is helpful. If you have ANY questions, comments, or criticisms about this please feel free to post a reply.
Later...
-
Apr 14th, 2000, 01:41 AM
#14
Thread Starter
transcendental analytic
Thanks again!
It works but then another problem, It seemed like I didn't have this key you posted. Maybe I have done my winamp installation in a different way? I had a not installed version of Winamp 2.23 copied to my HD, (to get all my old plugins) over wich I have installed other versions, I have now winamp 2.61.
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Apr 14th, 2000, 02:04 AM
#15
Addicted Member
If the only reason why you didn't do an install of Winamp is because you wanted to keep your plug-ins (and/or skins),
you can simply copy the Plugns and Skins directories out of the Winamp directory, install a full version of Winamp,
and then copy the two folders into the new Winamp directory.
If you don't want to try this then you can try doing a full install on a another computer or looking at a computer that
already has it installed (if possible), look in the registry on those computers, they should have this Key.
I recommend doing a full install on your computer though, it pays off in the end if your developing apps for it.
If I recall correctly, Winamp reads those two directories when it starts up to update it Plug-ins and Skins,
so you should be able to copy them out and put them back in after you install.
Then again if you didn't find the Key on your computer, then chances are that the same anomally could occur on other computers,
there-by it is not a very reliable method to find the Winamp path.
It does go there on a regular full install though.
Later.
[Edited by SonGouki on 04-14-2000 at 03:37 PM]
-
Apr 14th, 2000, 02:24 AM
#16
Thread Starter
transcendental analytic
I had a not installed version of Winamp 2.23 copied to my HD, (to get all my old plugins) over wich I have installed other versions
Ok, I quote myself now, thats funny. But no, I found my winamp 2.23 intact on another dir, It seems like I have copied those plugins and skins into a later installed I don't know if it is Winamp 2.5 or 2.6 but they surely are installed. If everyone else have this key, it's not a problem, cuz for myself I created the path key with value that does end without "\" Is this correct?
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Apr 14th, 2000, 03:52 AM
#17
Addicted Member
Sorry kedaman,
On my computer the Values are as follows:
(default) = "C:\PROGRAM FILES\WINAMP\Winamp.exe"
Path = "C:\PROGRAM FILES\WINAMP"
My version is 2.61 as well, but before you use this in your program I think you should check some other computers, or maybe post it as a question in a new thread asking people what it's like on their computer. I'm just saying that it's this way on all the computers I've seen, or when I've done a fresh install, it could have carried over from an earlier version though. I think that more testing is definitely in order though. Either way I'll be happy to aid you in any way I can.
Later.
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
|