How to retrieve string values (where i made a mistake?)

  • Thread starter Thread starter Leszek Gruszka
  • Start date Start date
L

Leszek Gruszka

When i'm trying to retrieve string key from registry that was never written,
i've got a trash string and error that "Cast from string ""?????????" to
type 'Double' is not valid.

It's everytime, that key was never use (defined).
In key is value "Brak tekstu". Where is a problem?

Function LegalNoticeCaption(ByVal strKomputer As String)
Dim oreg
oreg = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" &
strKomputer & "\root\default:StdRegProv")
Dim dwValue = Nothing
Dim vLegalNoticeCaption = Nothing
Dim strKeyPath = "Software\Microsoft\Windows\CurrentVersion\Policies\System"
Dim strValueName = "LegalNoticeCaption"
oreg.getStringValue(HKEY_LOCAL_MACHINE, strKeyPath, strValueName, dwValue)
If dwValue Is Nothing Then
vLegalNoticeCaption = "empty"
Else
dwValue = vLegalNoticeCaption
End If
MsgBox(dwValue)
End Function
 
Leszek,

The most simple method is to use the default when there is something brak,
Reg = Registry.CurrentUser.CreateSubKey("Software\Moje\Leszek")

pFormWidth = CInt(Reg.GetValue("Width", 700))

pFormHeight = CInt(Reg.GetValue("Height", 400))

I hope this helps?

Cor
 
Back
Top