Click here to Skip to main content
15,891,423 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: How to Extend the InitializeComponents to my code in VB2008/2010 Pin
QuickBooksDev21-Jan-13 9:38
QuickBooksDev21-Jan-13 9:38 
QuestionMS Graph in Access 2007 VBA Application Pin
satcomengineer19-Jan-13 7:48
satcomengineer19-Jan-13 7:48 
AnswerRe: MS Graph in Access 2007 VBA Application Pin
Eddy Vluggen20-Jan-13 2:38
professionalEddy Vluggen20-Jan-13 2:38 
Questionvb6.0 Pin
Barun sengupta18-Jan-13 21:39
Barun sengupta18-Jan-13 21:39 
AnswerRe: vb6.0 Pin
Eddy Vluggen20-Jan-13 2:36
professionalEddy Vluggen20-Jan-13 2:36 
QuestionDecoding USBSTOR Registry Entry in VB Pin
SantLou4017-Jan-13 16:06
SantLou4017-Jan-13 16:06 
AnswerRe: Decoding USBSTOR Registry Entry in VB Pin
ChandraRam17-Jan-13 20:03
ChandraRam17-Jan-13 20:03 
AnswerRe: Decoding USBSTOR Registry Entry in VB Pin
Alan N18-Jan-13 1:21
Alan N18-Jan-13 1:21 
Your code is essentially correct but what you haven't done is to read the type of data stored in each name-value pair so that the correct cast can be applied.

The raw data obtained from GetValue(valueName) is typed as Object and the ToString() conversion gives a correct representation in most cases, the exceptions being when the actual type is an array (REG_BINARY, REG_MULTI_SZ)

The technique is read the type via GetValueKind(valueName) and then apply a cast to the Object returned from GetValue(valueName). The incomplete method below shows the basics and in your case formatting the values ready for display should be done in the gaps left as "do something appropriate".

VB
Private Sub InterpretValue(rawValue as Object, interpretAsType as RegistryValueKind)
    Select Case interpretAsType
        Case RegistryValueKind.Binary
          ' REG_BINARY
            Dim byteArray As Byte() = DirectCast(rawValue, Byte())
            ' Do something appropriate
            Exit Select
        Case RegistryValueKind.DWord
          ' REG_DWORD
            Dim signedValue32 As Integer = DirectCast(rawValue, Integer)
            ' Do something appropriate
            Exit Select
        Case RegistryValueKind.QWord
          ' REG_QWORD
            Dim signedValue64 As Long = DirectCast(rawValue, Long)
            ' Do something appropriate
            Exit Select
        Case RegistryValueKind.Unknown, RegistryValueKind.String, RegistryValueKind.ExpandString
            Dim stringValue as String = rawValue.ToString()
            ' Do something appropriate
            Exit Select
        Case RegistryValueKind.MultiString
          ' REG_MULTI_SZ
            Dim stringArray As String() = TryCast(rawValue, String())
            ' Do something appropriate
            Exit Select
    End Select
End Sub

GeneralRe: Decoding USBSTOR Registry Entry in VB Pin
SantLou4018-Jan-13 1:47
SantLou4018-Jan-13 1:47 
GeneralRe: Decoding USBSTOR Registry Entry in VB Pin
Alan N18-Jan-13 4:05
Alan N18-Jan-13 4:05 
JokeRe: Decoding USBSTOR Registry Entry in VB Pin
Jeffnogueira22-Jan-13 4:31
Jeffnogueira22-Jan-13 4:31 
QuestionVB.NET ReportViewer too many Page Breaks rendered Pin
SantLou4017-Jan-13 3:39
SantLou4017-Jan-13 3:39 
AnswerRe: VB.NET ReportViewer too many Page Breaks rendered Pin
ChandraRam17-Jan-13 20:04
ChandraRam17-Jan-13 20:04 
GeneralRe: VB.NET ReportViewer too many Page Breaks rendered Pin
SantLou4018-Jan-13 1:39
SantLou4018-Jan-13 1:39 
Questioncontrol 5 appliances using pc's parallel port[vb.net 2010] Pin
Lord Christian15-Jan-13 20:10
Lord Christian15-Jan-13 20:10 
AnswerRe: control 5 appliances using pc's parallel port[vb.net 2010] Pin
Bernhard Hiller15-Jan-13 20:42
Bernhard Hiller15-Jan-13 20:42 
GeneralRe: control 5 appliances using pc's parallel port[vb.net 2010] Pin
Lord Christian17-Jan-13 7:15
Lord Christian17-Jan-13 7:15 
AnswerRe: control 5 appliances using pc's parallel port[vb.net 2010] Pin
Richard MacCutchan15-Jan-13 22:59
mveRichard MacCutchan15-Jan-13 22:59 
GeneralRe: control 5 appliances using pc's parallel port[vb.net 2010] Pin
Lord Christian17-Jan-13 6:56
Lord Christian17-Jan-13 6:56 
GeneralRe: control 5 appliances using pc's parallel port[vb.net 2010] Pin
Richard MacCutchan17-Jan-13 7:10
mveRichard MacCutchan17-Jan-13 7:10 
GeneralRe: control 5 appliances using pc's parallel port[vb.net 2010] Pin
Lord Christian17-Jan-13 7:33
Lord Christian17-Jan-13 7:33 
GeneralRe: control 5 appliances using pc's parallel port[vb.net 2010] Pin
Richard MacCutchan17-Jan-13 22:51
mveRichard MacCutchan17-Jan-13 22:51 
GeneralRe: control 5 appliances using pc's parallel port[vb.net 2010] Pin
Lord Christian18-Jan-13 4:58
Lord Christian18-Jan-13 4:58 
GeneralRe: control 5 appliances using pc's parallel port[vb.net 2010] Pin
Richard MacCutchan18-Jan-13 5:10
mveRichard MacCutchan18-Jan-13 5:10 
GeneralRe: control 5 appliances using pc's parallel port[vb.net 2010] Pin
Lord Christian20-Jan-13 18:55
Lord Christian20-Jan-13 18:55 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.