Results 1 to 3 of 3

Thread: Save in registry as a Name

  1. #1

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

    Save in registry as a Name

    I have been using this code from the API-Guide. I am new to API's in general.
    It creates a REG_DWORD in the directory I want.
    How do I name the entry, for example I would like to store the position of the form when it is closed, with Left, Top, Height, Width?

    vb Code:
    1. Dim Result As Long
    2. 'Check if the specified key exists
    3. RegOpenKeyEx HKEY_LOCAL_MACHINE, vSubKey, 0, KEY_ALL_ACCESS, Ret
    4. 'If the key doesn't exist, we create it
    5. If Result = 0 Then
    6.     'Create a new key
    7.     RegCreateKeyEx HKEY_LOCAL_MACHINE, vSubKey, 0, "REG_DWORD", REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, ByVal 0&, Result, Ret
    8.     If Result = 0 Then
    9.         MsgBox "Error while creating the Key!!"
    10.         Exit Sub
    11.     End If
    12. End If

    This runs and creates the entry, but when I run the app a second time, it doesn't create another entry, so I guess I have to insert a name, or text somewhere.
    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
    PowerPoster
    Join Date
    Feb 2006
    Location
    East of NYC, USA
    Posts
    5,691

    Re: Save in registry as a Name

    When you run the app the second time it's not supposed to create another entry, since there's already an entry. You can only have one unambiguously-named entry in the registry. If you h ad two, which one would you read when you read that entry name?
    The most difficult part of developing a program is understanding the problem.
    The second most difficult part is deciding how you're going to solve the problem.
    Actually writing the program (translating your solution into some computer language) is the easiest part.

    Please indent your code and use [HIGHLIGHT="VB"] [/HIGHLIGHT] tags around it to make it easier to read.

    Please Help Us To Save Ana

  3. #3

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

    Re: Save in registry as a Name

    Thanks Al42

    If you take a look at this thread, you will see better at what I was after.
    I was trying to create an entry into the registry that was named, then create another o a different name, not actually another of the same name.
    I didn't explain myself too well.
    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