Hmmm... a few issues... (I've not actually run this....)
vb Code:
Dim vSubKey As String Dim Ret As Long Dim Result As Long Dim lngKeyHandle As Long vSubKey = "Software\Deftech\CodeLibrary\2.0" 'Check if the specified key exists Result = RegOpenKeyEx(HKEY_LOCAL_MACHINE, vSubKey, 0&, KEY_ALL_ACCESS, lngKeyHandle) If Result <> 0 Then 'Key doesn't exist. 0 signifies success. 'Create a new key Result = RegCreateKeyEx(HKEY_LOCAL_MACHINE, vSubKey, ByVal 0&, REG_DWORD, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, ByVal 0&, lngKeyHandle, Ret) If Result <> 0 Then '0 signifies success. MsgBox "Error while creating the Key!!" Exit Sub End If 'Open the new key. RegOpenKeyEx HKEY_LOCAL_MACHINE, vSubKey, 0&, KEY_ALL_ACCESS, lngKeyHandle End If 'Now that we have a valid handle... 'Give it a value of say, 25 'The 4 signifies the length of the value. For a DWORD (Long) it's always 4. RegSetValueEx lngKeyHandle, HKEY_LOCAL_MACHINE, vSubKey, 0&, "REG_DWORD", 25, 4 RegCloseKey lngKeyHandle




Reply With Quote