Results 1 to 34 of 34

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

Hybrid View

  1. #1

    Thread Starter
    Frenzied Member aikidokid's Avatar
    Join Date
    Aug 2002
    Location
    Bristol, UK
    Posts
    1,968

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

    YEAHHHH

    I've finally got this sorted, reading and writing

    A big thanks to SCHOOLBUSDRIVER for all you help, time and patience.

    It's people like you that make this forum what it is.
    If somebody helps you, take time to RATE the post. I do.

    "FAILURE IS NOT AN OPTION. It comes bundled with the software."

    Below are some of the threads that have helped me along the way:

    CodeBank submission:
    Listview Backcolor (without subclassing)

    Loading Treeview Nodes From A Database, Creating Registry Keys, Count Number of Lines in TextBox , Excellent RichTextBox Tricks & Tips
    Ideas & Screen Shots For A Code Library App
    How to do Data validation in Excel, Conditional Formating in Excel

  2. #2

    Thread Starter
    Frenzied Member aikidokid's Avatar
    Join Date
    Aug 2002
    Location
    Bristol, UK
    Posts
    1,968

    Re: [RESOLVED by schoolbusdriver]Save to registry, but it doesn't!

    Hmm, thought I did.

    I am getting the error:
    User defined type may not be passed ByVal

    on this line of code:

    vb Code:
    1. Result = RegCreateKeyEx(HKEY_LOCAL_MACHINE, "StartOption", ByVal 0&, REG_DWORD, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, ByVal 0&, lngKeyHandle, Ret)

    on the "ByVal 0&" part.

    I have this line of code elsewhere and it works without this error:

    vb Code:
    1. Result = RegCreateKeyEx(HKEY_LOCAL_MACHINE, "Left", ByVal 0&, REG_DWORD, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, ByVal 0&, lngKeyHandle, Ret)

    Now I'm not too sure what this means, but looking at the API code it says:
    lpSecurityAttributes As Any
    But when I type the code out, the intellisense (or what ever the tooltiptext is called) it says
    lpSecurityAttributes As SECURITY_ATTRIBUTES

    Does this matter, or make any sense?

    vb Code:
    1. Dim lngKeyHandle As Long
    2. Dim Ret As Long
    3. Dim Result As Long
    4.  
    5. Const strSubKey = "Software\Deftech\CodeLibrary\2.0"
    6.  
    7. 'SelectedOption holds the option button index number
    8. 'Check if the specified key exists
    9. Result = RegOpenKeyEx(HKEY_LOCAL_MACHINE, strSubKey, 0&, KEY_ALL_ACCESS, lngKeyHandle)
    10.  
    11. If Result <> 0 Then
    12.     'Key doesn't exist. 0 signifies success.
    13.     'Create a new key
    14.     Result = RegCreateKeyEx(HKEY_LOCAL_MACHINE, "StartOption", ByVal 0&, REG_DWORD, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, ByVal 0&, lngKeyHandle, Ret)
    15.     If Result <> 0 Then '0 signifies success.
    16.         MsgBox "Error while creating the Key!!"
    17.         Exit Sub
    18.     End If
    19.  
    20.     'Open the new key.
    21.     RegOpenKeyEx HKEY_LOCAL_MACHINE, "StartOption", 0&, KEY_ALL_ACCESS, lngKeyHandle
    22. End If
    23.  
    24. 'Now that we have a valid handle - Give it a value
    25. 'The 4 signifies the length of the value. For a DWORD (Long) it's always 4.
    26. RegSetValueEx lngKeyHandle, "StartOption", 0&, REG_DWORD, SelectedOption, 4
    27. 'close the opened key
    28. RegCloseKey lngKeyHandle
    Last edited by aikidokid; Mar 9th, 2007 at 08:46 AM.
    If somebody helps you, take time to RATE the post. I do.

    "FAILURE IS NOT AN OPTION. It comes bundled with the software."

    Below are some of the threads that have helped me along the way:

    CodeBank submission:
    Listview Backcolor (without subclassing)

    Loading Treeview Nodes From A Database, Creating Registry Keys, Count Number of Lines in TextBox , Excellent RichTextBox Tricks & Tips
    Ideas & Screen Shots For A Code Library App
    How to do Data validation in Excel, Conditional Formating in Excel

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