Please support our Visual Basic 4 / 5 / 6 advertiser: Programming Forums
![]() |
•
•
Join Date: Jan 2006
Posts: 1
Reputation:
Rep Power: 0
Solved Threads: 0
i want to set this to read from the "cd Quality" key
anyone help me ?
ive tried changing key2, "Cd Quality", with no luck ! where am i going wrong ?
anyone help me ?
ive tried changing key2, "Cd Quality", with no luck ! where am i going wrong ?
Private Function GetDefaultWaveFormat(format As WAVEFORMAT) As Boolean '//////////////////////////////////////////////////////////////////////////////////// ' This user-defined function retrieves the default wave format from the registry. '//////////////////////////////////////////////////////////////////////////////////// Dim rc As Long Dim key1 As Long Dim key2 As Long Dim formatName As String * 50 Dim length As Long ' Initialize return code GetDefaultWaveFormat = False rc = RegOpenKeyEx(HKEY_CURRENT_USER, _ "Software\Microsoft\Multimedia\Audio", _ 0, _ KEY_READ, _ key1) If (rc <> 0) Then Exit Function End If length = Len(formatName) rc = RegQueryValueString(key1, "DefaultFormat", 0, 0, formatName, length) If (NO_ERROR = rc) Then rc = RegOpenKeyEx(HKEY_CURRENT_USER, _ "Software\Microsoft\Multimedia\Audio\WaveFormats", _ 0, _ KEY_READ, _ key2) If (NO_ERROR = rc) Then length = Len(format) rc = RegQueryValueEx(key2, _ formatName, _ 0, _ 0, _ format, _ length) RegCloseKey key2 If (NO_ERROR = rc) Then GetDefaultWaveFormat = True End If End If End If RegCloseKey key1 End Function
•
•
Join Date: Dec 2004
Location: Lincoln Park, Michigan
Posts: 1,855
Reputation:
Rep Power: 8
Solved Threads: 116
I know that the API is a fun place to play around, but you should really consider using windows scripting for that task....
Post Edit: Sorry, I was reading it in a hurry, the CD Quality's key is NOT a string (REG_SZ), it's a binary or Hex... I'll keep digging around and let you know what I find.
dim NewValue as string
dim WSH
set WSH = createobject("WScript.Shell")
NewValue = "Whatever you want CD Quality's Value To Be"
WSH.regwrite "HKEY_CURRENT_USER\Software\Microsoft\Multimedia\Audio\WaveFormats\CD Quality", NewValue, "REG_SZ"
set WSH = nothingPost Edit: Sorry, I was reading it in a hurry, the CD Quality's key is NOT a string (REG_SZ), it's a binary or Hex... I'll keep digging around and let you know what I find.
I honestly don't know. It rattled my cage when I tried all of the registry access methods I knew! I then tried the sRegistry class from:
http://www.vbaccelerator.com/home/VB...ol/article.asp
which does the trick... you'll have to download the class module and add it to your project.
I dropped a list box and a command button on the form and [eventually] sussed out that the returned value is a 16-byte long byte array which you can then convert into something useful.
The code here for the button enumerates the keys in /.../WaveFormats and displays the value of each in the same format as Regedit. Presumably you could then do maths on them to get 44100 16 bit etc.
[code]Private Sub Command1_Click()
Dim c As New cRegistry
Dim sKeys() As String, iKeyCount As Long
Dim ikey As Long
Dim ibyte As Long
Dim vr As Variant
Dim sOut As String
Dim sTemp As String
With c
.ClassKey = HKEY_CURRENT_USER
.SectionKey = "Software\Microsoft\Multimedia\Audio\WaveFormats"
ret = .EnumerateValues(sKeys(), iKeyCount)
For ikey = 1 To iKeyCount
Debug.Print sKeys(ikey)
.ValueKey = sKeys(ikey)
.ValueType = REG_BINARY
vr = .Value
'read bytes in the byte array and assemble into human-readable form
sOut = ""
For ibyte = LBound(vr) To UBound(vr)
sTemp = Hex$(vr(ibyte))
If Len(sTemp) = 1 Then sTemp = "0" & sTemp
sOut = sOut & sTemp & " "
Next ibyte
'write to the list box
List1.AddItem sKeys(ikey) & ":" & sOut
Next ikey
End With
End Sub
[code]
I hope you can interpret what this returns!!
[IMG]image2.jpg[/IMG]
I still think there's a simpler way and that may be to initialise the sound card using waveindevcaps api and then read the formats if that's possible. In the absence of anything else, the default values should be returned.
Hope this helps
AlanC
http://www.vbaccelerator.com/home/VB...ol/article.asp
which does the trick... you'll have to download the class module and add it to your project.
I dropped a list box and a command button on the form and [eventually] sussed out that the returned value is a 16-byte long byte array which you can then convert into something useful.
The code here for the button enumerates the keys in /.../WaveFormats and displays the value of each in the same format as Regedit. Presumably you could then do maths on them to get 44100 16 bit etc.
[code]Private Sub Command1_Click()
Dim c As New cRegistry
Dim sKeys() As String, iKeyCount As Long
Dim ikey As Long
Dim ibyte As Long
Dim vr As Variant
Dim sOut As String
Dim sTemp As String
With c
.ClassKey = HKEY_CURRENT_USER
.SectionKey = "Software\Microsoft\Multimedia\Audio\WaveFormats"
ret = .EnumerateValues(sKeys(), iKeyCount)
For ikey = 1 To iKeyCount
Debug.Print sKeys(ikey)
.ValueKey = sKeys(ikey)
.ValueType = REG_BINARY
vr = .Value
'read bytes in the byte array and assemble into human-readable form
sOut = ""
For ibyte = LBound(vr) To UBound(vr)
sTemp = Hex$(vr(ibyte))
If Len(sTemp) = 1 Then sTemp = "0" & sTemp
sOut = sOut & sTemp & " "
Next ibyte
'write to the list box
List1.AddItem sKeys(ikey) & ":" & sOut
Next ikey
End With
End Sub
[code]
I hope you can interpret what this returns!!
[IMG]image2.jpg[/IMG]
I still think there's a simpler way and that may be to initialise the sound card using waveindevcaps api and then read the formats if that's possible. In the absence of anything else, the default values should be returned.
Hope this helps
AlanC
•
•
Join Date: Dec 2004
Location: Lincoln Park, Michigan
Posts: 1,855
Reputation:
Rep Power: 8
Solved Threads: 116
![]() |
Similar Threads
Other Threads in the Visual Basic 4 / 5 / 6 Forum
- Cannot view All Folders in WinME (Windows 9x / Me)
- Computer powers up, does not boot (Troubleshooting Dead Machines)
Other Threads in the Visual Basic 4 / 5 / 6 Forum
- Previous Thread: Can't run qbasic on XP...help?
- Next Thread: Need Help with a function...
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)






Linear Mode