|
-
Jul 25th, 2009, 08:33 PM
#1
Thread Starter
Fanatic Member
[RESOLVED] read REG_NONE IconUnderline value
Hello,
i'am trying to read the value IconUnderline which exist on that path
Code:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\IconUnderline
i never worked beforewith REG_NONE
Thanks
Last edited by killer7k; Jul 26th, 2009 at 08:04 AM.
-
Jul 25th, 2009, 10:50 PM
#2
Re: read REG_NONE IconUnderline value
check the key, shows with the type he says
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
-
Jul 25th, 2009, 11:32 PM
#3
Re: read REG_NONE IconUnderline value
Thank you for reporting this issue with the RegistryKey.GetValue method.
Unfortunately GetValue does not support reading values of type REG_NONE or REG_LINK at this time. We will consider adding this support for version 3 of the .NET Framework.
Thanks,
Josh Free
from http://connect.microsoft.com/VisualS...edbackID=97603
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
-
Jul 26th, 2009, 03:14 AM
#4
Re: read REG_NONE IconUnderline value
A REG_NONE is merely a string represented in hex. Read it just as you would a REG_SZ string without a null terminating character. You need to use the registry APIs to do this, as it is not supported by WSH or WMI.
In NET, you read it into a byte array (with GetValue) then optionally use BitConverter to convert it to a string.
Last edited by schoolbusdriver; Jul 26th, 2009 at 03:20 AM.
Reason: Clarification
-
Jul 26th, 2009, 05:45 AM
#5
Thread Starter
Fanatic Member
Re: read REG_NONE IconUnderline value
can you some help with a sample
basic code reading registry dont work with the case REG_NONE
it show blank only
Thanks
-
Jul 26th, 2009, 10:16 AM
#6
Re: read REG_NONE IconUnderline value
Post the code that you have already and we can go through it to show you where you need to make changes.
-
Jul 26th, 2009, 12:44 PM
#7
Thread Starter
Fanatic Member
Re: read REG_NONE IconUnderline value
Hi i use this code for reading but show blank
Code:
Private Function Registry_Read(Key_Path, Key_Name) As Variant
On Error Resume Next
Dim Registry As Object
Set Registry = CreateObject("WScript.Shell")
Registry_Read = Registry.RegRead(Key_Path & Key_Name)
End Function
Private Sub Form_Load()
MsgBox Registry_Read("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\", "IconUnderline")
End Sub
-
Jul 27th, 2009, 03:19 AM
#8
Re: read REG_NONE IconUnderline value
Use this instead. A REG_NONE can contain anything, so the data type you specify for lpData in RegQueryValueEx determines the outcome. In this case IconUnderline appears to be a number. The following example can provide either a hex string or a number.
vb Code:
'Form level code.
Option Explicit
Private Sub Form_Load()
Const HKEY_LOCAL_MACHINE = &H80000002
Const SUBKEY = "SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer"
Const VALUE_NAME = "IconUnderline"
MsgBox RegReadNoneString(HKEY_LOCAL_MACHINE, SUBKEY, VALUE_NAME)
End Sub
vb Code:
'Module level code.
Option Explicit
Public Declare Function RegOpenKeyEx Lib "advapi32.dll" Alias "RegOpenKeyExA" _
(ByVal Hkey As Long, ByVal lpSubKey As String, ByVal ulOptions As Long, _
ByVal samDesired As Long, ByRef phkResult As Long) As Long
Public Declare Function RegQueryValueEx Lib "advapi32.dll" Alias "RegQueryValueExA" _
(ByVal Hkey As Long, ByVal lpValueName As String, ByVal lpReserved As Long, _
ByRef lpType As Long, ByRef lpData As Any, ByRef lpcbData As Long) As Long
Public Declare Function RegCloseKey Lib "advapi32.dll" (ByVal Hkey As Long) As Long
Public Const REG_OPTION_RESERVED = 0&
Public Const KEY_QUERY_VALUE = &H1
Public Const ERROR_SUCCESS = 0&
Public Const ERROR_MORE_DATA = 234
Public Const REG_NONE = 0
Public Function RegReadNoneString(lngHKey As Long, strSubKey As String, strValueName As String) As String
Dim lngErrVal As Long
Dim lngKeyHandle As Long
Dim lngDataType As Long
Dim lngDataSize As Long
Dim intIndex As Integer
Dim bytRetVal() As Byte
Dim strRetVal As String
Dim lngRetVal As Long
'Open the new key.
lngErrVal = RegOpenKeyEx(lngHKey, strSubKey, REG_OPTION_RESERVED, KEY_QUERY_VALUE, lngKeyHandle)
If lngErrVal = ERROR_SUCCESS Then
'Get the key`s data length. It should return ERROR_MORE_DATA.
lngErrVal = RegQueryValueEx(lngKeyHandle, strValueName, REG_OPTION_RESERVED, lngDataType, 0&, lngDataSize)
'Size the data array.
ReDim bytRetVal(lngDataSize)
If lngErrVal = ERROR_MORE_DATA Then
'Test for REG_NONE.
If lngDataType = REG_NONE Then
'Get the current value.
lngErrVal = RegQueryValueEx(lngKeyHandle, strValueName, REG_OPTION_RESERVED, 0&, bytRetVal(0), lngDataSize)
End If
''////////////////////////////////////////////////
''Format the data into a binary string.
For intIndex = 0 To lngDataSize - 1
strRetVal = strRetVal & Right("00" & bytRetVal(intIndex), 2) & " "
Next
strRetVal = Left$(strRetVal, Len(strRetVal) - 1)
RegReadNoneString = strRetVal
''////////////////////////////////////////////////
''Alternative for a LONG.
' lngErrVal = RegQueryValueEx(lngKeyHandle, strValueName, REG_OPTION_RESERVED, 0&, lngRetVal, lngDataSize)
' RegReadNoneString = CStr(lngRetVal)
''////////////////////////////////////////////////
End If
End If
'Close any key opened with RegOpenKeyEx.
Call RegCloseKey(lngKeyHandle)
End Function
-
Jul 27th, 2009, 08:25 AM
#9
Thread Starter
Fanatic Member
Re: read REG_NONE IconUnderline value
Hi schoolbusdriver ,
Thanks for your sample but seem that dont work with other
i tested with IconUnderline is fine it return the true value
but when i tested with others it show wrong value
how can that happen ?
here you how it look like

Thanks
-
Jul 27th, 2009, 01:29 PM
#10
Re: read REG_NONE IconUnderline value
 Originally Posted by schoolbusdriver
A REG_NONE can contain anything, so the data type you specify for lpData in RegQueryValueEx determines the outcome.
Unlike other data types, the data in a REG_NONE is undefined, so it is up to YOU to interpret the data. The "wrong" data you're showing is actually the decimal value of the hex data....
As it is 5 bytes long it is probably a string - the last "00" being a null, so instead of using
Code:
lngErrVal = RegQueryValueEx(lngKeyHandle, strValueName, REG_OPTION_RESERVED, 0&, bytRetVal(0), lngDataSize)
or
Code:
lngErrVal = RegQueryValueEx(lngKeyHandle, strValueName, REG_OPTION_RESERVED, 0&, lngRetVal, lngDataSize)
try
Code:
lngErrVal = RegQueryValueEx(lngKeyHandle, strValueName, REG_OPTION_RESERVED, 0&, strRetVal, lngDataSize)
Bear in mind that the data may also be mix of data types that are supposed to be put into a UDT - so unless you know the structure of the UDT it may not be decipherable.
If it's not a value that you have written, count the bytes.......
-
Jul 27th, 2009, 02:32 PM
#11
Thread Starter
Fanatic Member
Re: read REG_NONE IconUnderline value
Hi ,
When you added it crash application
Code:
lngErrVal = RegQueryValueEx(lngKeyHandle, strValueName, REG_OPTION_RESERVED, 0&, strRetVal, lngDataSize)
unless there is a way of this crash to be fixed i will use the byte
Code:
lngErrVal = RegQueryValueEx(lngKeyHandle, strValueName, REG_OPTION_RESERVED, 0&, bytRetVal(0), lngDataSize)
and convert it from Dec2Hex even sometimes it got more than 5 byte..
do you have any tips or good idea schoolbusdriver ?
Thanks
Last edited by killer7k; Jul 27th, 2009 at 02:38 PM.
-
Jul 27th, 2009, 04:28 PM
#12
Re: read REG_NONE IconUnderline value
My bad, it should have been "ByVal strRetVal" i.e.
vb Code:
Public Function RegReadNoneString(lngHKey As Long, strSubKey As String, strValueName As String) As String
Dim lngErrVal As Long
Dim lngKeyHandle As Long
Dim lngDataType As Long
Dim lngDataSize As Long
Dim strRetVal As String
'Open the new key.
lngErrVal = RegOpenKeyEx(lngHKey, strSubKey, REG_OPTION_RESERVED, KEY_QUERY_VALUE, lngKeyHandle)
If lngErrVal = ERROR_SUCCESS Then
'Get the key`s data length. It should return ERROR_MORE_DATA.
lngErrVal = RegQueryValueEx(lngKeyHandle, strValueName, REG_OPTION_RESERVED, lngDataType, 0&, lngDataSize)
If lngErrVal = ERROR_MORE_DATA Then
'Test for REG_NONE.
If lngDataType = REG_NONE Then
'Size the string.
strRetVal = Space$(lngDataSize)
'Get the current value.
lngErrVal = RegQueryValueEx(lngKeyHandle, strValueName, REG_OPTION_RESERVED, 0&, ByVal strRetVal, lngDataSize)
RegReadNoneString = strRetVal
End If
End If
End If
'Close any key opened with RegOpenKeyEx.
Call RegCloseKey(lngKeyHandle)
End Function
How you convert it depends on what you want to display.
If you are confident handling the registry you could try the following.
Create a plain text file containing:
Code:
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer]
"Test"=hex(0):3e,3d,3c,3a,00
Rename it to "test.reg" and double click on it and merge it with the registry. This will put the binary data you mentioned into the same subkey that contains "IconUnderline".
Use the code in this post to read the value "Test". The message box will display the ascii string:- >=<:
Don't forget to delete it when you've done.
With a REG_NONE it's a case of "what do you want to do". Because it's undefined you could, for example, use it to store an encrypted gif of a password 
Any other tips will cost you lots of hard cash
Last edited by schoolbusdriver; Jul 28th, 2009 at 11:33 AM.
-
Jul 27th, 2009, 06:14 PM
#13
Thread Starter
Fanatic Member
Re: read REG_NONE IconUnderline value
Hi,
your last update didnt work show blank
so i think i will stay on Dec2hex way work for now
i really appreciate your help schoolbusdriver
cheerz & Thanks
Last edited by killer7k; Jul 27th, 2009 at 07:07 PM.
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
|