|
-
August 12th, 2004, 09:15 AM
#1
RegRead error
How can i find out if the RegRead operation was successful?
-
August 12th, 2004, 09:58 AM
#2
whats this message is related to
Ritesh Tandon
(Sr. Software Engineer)
-
August 12th, 2004, 11:15 AM
#3
wscripting technology?
Then: if you read something different by default values of type of key_value
you're reading, you read something.
...at present time, using mainly Net 4.0, Vs 2010
Special thanks to Lothar "the Great" Haensler, Chris Eastwood , dr_Michael, ClearCode, Iouri and
all the other wonderful people who made and make Codeguru a great place.
Come back soon, you Gurus.
-
August 12th, 2004, 03:38 PM
#4
RegRead will create an automation error, so you can use ON ERROR to determine if is was successfull or not in reading, say for example:
Code:
Option Explicit
Private Sub Command1_Click()
On Error GoTo ErrReadingRegistry
Dim objShell As New WshShell
Dim strReturn As String
'This works "Systemtray"
strReturn = objShell.RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run\Systemtray")
MsgBox strReturn
'This doesnt "Systemtray OOOPPPSS" and return an error
strReturn = objShell.RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run\Systemtray OOOPPPSS")
MsgBox strReturn
Exit Sub
ErrReadingRegistry:
MsgBox "Error # " & Err.Number & vbCrLf & _
"Description: " & Err.Description
End Sub
JeffB
-
August 13th, 2004, 01:59 AM
#5
Hallo Savitar,
here another way to do it
Code:
'==========================================================
' Name: ERROR_SUCCESS
' Purpose: All the access bits, not including MAXIMUM_ALLOWED,
' are granted and the GrantedAccessMask member is not zero.
' Remarks:
'==========================================================
Public Const ERROR_SUCCESS = 0&
'==========================================================
' Name: ERROR_CODE
' Purpose: Error code
' Remarks:
'==========================================================
Public Const ERROR_CODE = -1&
'==========================================================
' Name: fWSHGetRegKey
' Input:
' ByRef STRNAME As String
' ByRef vValue As Variant
' Output: Long
' Purpose: Returns the value of a key or value-name from the registry
' for the following value type REG_SZ, REG_DWORD, REG_BINARY,
' REG_EXPAND_SZ, REG_MULTI_SZ
' Remarks:
'==========================================================
Public Function fWSHGetRegKey(STRNAME As String, vValue As Variant) As Long
vValue = objWSH.RegRead(STRNAME)
If Err.Number <> ERROR_SUCCESS Then
fWSHGetRegKey = ERROR_CODE
End If
End Function
private myCallsub()
dim vValue as Variant
dim LngRetValue as long
dim strKey as String
strKey = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run\Systemtray"
LngRetValue = fWSHGetRegKey(strKey ,vValue )
if LngRetValue = ERROR_SUCCESS then
'You can use here the readed value saved on vValue as you want.
end if
end sub
james
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
|