Results 1 to 34 of 34

Thread: [RESOLVED by schoolbusdrive]Save to registry, but it doesn't!

Threaded View

  1. #13
    Fanatic Member schoolbusdriver's Avatar
    Join Date
    Jan 2006
    Location
    O'er yonder
    Posts
    1,020

    Re: Save to registry, but it doesn't!

    Hmmm... a few issues... (I've not actually run this....)

    vb Code:
    1. Dim vSubKey As String
    2. Dim Ret As Long
    3. Dim Result As Long
    4. Dim lngKeyHandle As Long
    5.  
    6.    vSubKey = "Software\Deftech\CodeLibrary\2.0"
    7.  
    8. 'Check if the specified key exists
    9.    Result = RegOpenKeyEx(HKEY_LOCAL_MACHINE, vSubKey, 0&, KEY_ALL_ACCESS, lngKeyHandle)
    10.    If Result <> 0 Then 'Key doesn't exist. 0 signifies success.
    11. 'Create a new key
    12.       Result = RegCreateKeyEx(HKEY_LOCAL_MACHINE, vSubKey, ByVal 0&, REG_DWORD, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, ByVal 0&, lngKeyHandle, Ret)
    13.       If Result <> 0 Then '0 signifies success.
    14.          MsgBox "Error while creating the Key!!"
    15.          Exit Sub
    16.       End If
    17. 'Open the new key.
    18.       RegOpenKeyEx HKEY_LOCAL_MACHINE, vSubKey, 0&, KEY_ALL_ACCESS, lngKeyHandle
    19.    End If
    20.  
    21. 'Now that we have a valid handle...
    22.  
    23. 'Give it a value of say, 25
    24. 'The 4 signifies the length of the value. For a DWORD (Long) it's always 4.
    25.     RegSetValueEx lngKeyHandle, HKEY_LOCAL_MACHINE, vSubKey, 0&, "REG_DWORD", 25, 4
    26.     RegCloseKey lngKeyHandle
    Last edited by schoolbusdriver; Mar 7th, 2007 at 06:11 PM. Reason: Found out how the =vb tag works

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width