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

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
 
C

Cor Ligthert

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top