Dim wsh, str
on error resume next
Set wsh = CreateObject("WScript.Shell")
str = wsh.RegRead("HKCR\.pid\") ' change to suit your key
'msgbox err.number
' if err.number = "-2147024894" then str = "filetype not registered"
msgbox str
Last edited by westconn1; Nov 8th, 2008 at 05:20 AM.
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case. Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
Dim wsh, str
on error resume next
Set wsh = CreateObject("WScript.Shell")
str = wsh.RegRead("HKCR\.pid\") ' change to suit your key
'msgbox err.number
' if err.number = "-2147024894" then str = "filetype not registered"
msgbox str
Nope, returns an empty value. I did subsitute with my key like this
i tested code in vb6, did not return for that key as i don't have, but worked ok for others
try a \ at the end of the string if it is a default value rather than a named value
"HKLM\SOFTWARE\RealNetworks\RealPlayer\version\"
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case. Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
Dim WshShell As Object
Dim strValue As String
Set WshShell = CreateObject("Wscript.Shell")
strValue = WshShell.RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\RealNetworks\RealPlayer\version")
Below also works
Code:
Dim VersionNumber As String
VersionNumber = sdaGetRegEntry("SOFTWARE\RealNetworks\RealPlayer", "version")
Now here is where neither one works and I don't understand why.
On this one I get a Type Mismatch
Code:
Dim WshShell As Object
Dim strValue As String
Set WshShell = CreateObject("Wscript.Shell")
strValue = WshShell.RegRead("HKEY_CURRENT_USER\Software\Microsoft\Windows\Shell\Bags\1\Desktop\ItemPos1024x768(1)")
And on this one.....
Please note that in the function sdaGetRegEntry
I changed this: If Not ERROR_SUCCESS = RegOpenKeyEx(HKEY_LOCAL_MACHINE, strSubKeys, 0&, KEY_READ, lngHandle) Then Exit Function
to this:
If Not ERROR_SUCCESS = RegOpenKeyEx(HKEY_CURRENT_USER, strSubKeys, 0&, KEY_READ, lngHandle) Then Exit Function
....and it just returns a null value.
Code:
Dim Positions As String
Positions = sdaGetRegEntry("Software\Microsoft\Windows\Shell\Bags\1\Desktop", "ItemPos1024x768(1)")
Set WshShell = CreateObject("Wscript.Shell")
strValue = WshShell.RegRead("HKEY_CURRENT_USER\Software\Microsoft\Windows\Shell\Bags\1\Desktop\ItemPos1024x768( 1)")
this works for me, but only as a variant OR variant array
returns an array of
0 to 3423 on my computer
it maybe that it should return a TYPE of some sort
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case. Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
Windows Scripting Host can't be used to retrieve strings from REG_BINARY entries, only numbers. It can't cope with UDTs either - there's a limit to the size of the returned array that it can handle.
EDIT: I had put some API code in here that would put REG_BINARY data in a UDT, but looking at the registry entry again, I've realised it contains an arry of UDTs. You'll first need to deduce the structure of the data the ValueName contains. Right-click in regedit and pick "Modify binary data" to copy/paste...
Last edited by schoolbusdriver; Nov 10th, 2008 at 06:12 AM.