RSS Forums RSS
Please support our Visual Basic 4 / 5 / 6 advertiser: Programming Forums
Views: 1934 | Replies: 6 | Thread Tools  Display Modes
Reply
Join Date: Jan 2006
Posts: 1
Reputation: Rattled_Cage is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
Rattled_Cage Rattled_Cage is offline Offline
Newbie Poster

not understanding reg read ! :(

  #1  
Feb 2nd, 2006
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 ?




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
Attached Images
File Type: jpg postr.jpg (14.2 KB, 4 views)
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Aug 2005
Location: El Paso, TX
Posts: 225
Reputation: extofer is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 5
extofer's Avatar
extofer extofer is offline Offline
Posting Whiz in Training

Re: not understanding reg read ! :(

  #2  
Feb 3rd, 2006
I know there is a GetSettings and SaveSettings function in VB. Perhaps you can look into them and pass parameters as to which registry needs to be altered (SaveSettings).
Reply With Quote  
Join Date: Dec 2004
Location: Lincoln Park, Michigan
Posts: 1,855
Reputation: Comatose is an unknown quantity at this point 
Rep Power: 8
Solved Threads: 116
Colleague
Comatose's Avatar
Comatose Comatose is offline Offline
Taboo Programmer

Re: not understanding reg read ! :(

  #3  
Feb 3rd, 2006
I know that the API is a fun place to play around, but you should really consider using windows scripting for that task....

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 = nothing

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.
Reply With Quote  
Join Date: Jul 2005
Posts: 31
Reputation: AlanC is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 1
AlanC's Avatar
AlanC AlanC is offline Offline
Light Poster

Re: not understanding reg read ! :(

  #4  
Feb 6th, 2006
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
Attached Images
File Type: jpg Image2.jpg (23.0 KB, 5 views)
Reply With Quote  
Join Date: Jul 2005
Posts: 31
Reputation: AlanC is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 1
AlanC's Avatar
AlanC AlanC is offline Offline
Light Poster

Re: not understanding reg read ! :(

  #5  
Feb 6th, 2006
OK moderator, what did I do wrong with the code?
How can I get the image to be embedded?
Reply With Quote  
Join Date: Dec 2004
Location: Lincoln Park, Michigan
Posts: 1,855
Reputation: Comatose is an unknown quantity at this point 
Rep Power: 8
Solved Threads: 116
Colleague
Comatose's Avatar
Comatose Comatose is offline Offline
Taboo Programmer

Re: not understanding reg read ! :(

  #6  
Feb 6th, 2006
I think it needs a full url
Reply With Quote  
Join Date: Jul 2005
Posts: 31
Reputation: AlanC is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 1
AlanC's Avatar
AlanC AlanC is offline Offline
Light Poster

Re: not understanding reg read ! :(

  #7  
Feb 7th, 2006
Thanks, Comatose
Rgds
AlanC
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.



Similar Threads
Other Threads in the Visual Basic 4 / 5 / 6 Forum
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes
Forums | Blogs | Tutorials | Code Snippets | Whitepapers | RSS Feeds | Advertising
All times are GMT -4. The time now is 3:20 pm.
Newsletter Archive - Sitemap - Privacy Statement - Acceptable Use Policy - Contact Us
Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC