Question problem in read a key from registry

pooya1072

Well-known member
Joined
Jul 5, 2012
Messages
84
Programming Experience
Beginner
hi
why the return value of this function is ZERO
i wrote this code to retrieval a value from registry
VB.NET:
Imports Microsoft.Win32
Module Variables
   
    Public Function GetTimePassed() As Integer
        Dim reg As RegistryKey
        Dim Value As Integer
        Dim KeyPath As String = "Software\ASW"
        Dim KeyName As String = "ASWValue"
        Try
            reg = Registry.CurrentUser.OpenSubKey(KeyPath, True)
            reg.GetValue(KeyName, Value)
            reg.Close()
        Catch ex As Exception
            MsgBox(ex.Message)
        End Try
        Return Value
    End Function
End Module

attention : the real value of key in the registry is 299
 
Back
Top