Creating, Updating and Deleting Registry Key
Are you sure above code is correct. It didn't delete the key I specified. I suspect an error over here.
Code:
Private Sub Command2_Click()
'~~> Check if the specified key exists under HKEY_LOCAL_MACHINE
RegOpenKeyEx HKEY_LOCAL_MACHINE, strKey, 0, KEY_ALL_ACCESS, Result
'~~> If the key doesn't exist, inform user
If Result = 0 Then
MsgBox "Key Doesn't Exist"
Else
'~~> Delete the key
RegDeleteKey Result, ""
'~~> close the handle
RegCloseKey Result
MsgBox "Deleted"
End If
End Sub
Re: Create Registry Key...
      
Re: Create Registry Key...
No that is incorrect...
Quote:
RegDeleteKey "HKEY_LOCAL_MACHINE", StrDeleteKey
Check my last post... I have already uploaded a sample...
Re: Create Registry Key...
Well I gotta go now...
Before I go, let me explain... Look at the declaration below... see the word in red...
Code:
'~~> The RegDeleteKey function deletes the specified key
Private Declare Function RegDeleteKey Lib "advapi32.dll" Alias "RegDeleteKeyA" _
(ByVal hKey As Long, ByVal lpSubKey As String) As Long
The value has to be a 'Long' and not a 'String'... and hence your code was failing... Go carefully through the sample I posted ;)
I hope it helps...
Also I think you should now rename your thread to
"Creating, Updating and Deleting Registry Key"
from
"Creating Registry Key" :lol:
tc :wave:
Re: Create Registry Key...
I'm successful now. I don't know how I should my gratitudeness towards you. Many many thanks to you again.