Results 1 to 6 of 6

Thread: RegSetValueEx function

  1. #1

    Thread Starter
    Hyperactive Member abhid's Avatar
    Join Date
    Nov 2001
    Location
    3rd rock from the sun
    Posts
    467

    RegSetValueEx function

    Hi all
    I want to create string keys and save a string in that key. For this
    purpose i am using RegSetValueEx function. But it saves some
    junk characters in registry.
    I am using it like
    VB Code:
    1. strDatabasePath = "d:\Project\FileName"
    2. lngcbdata = lngcbData = Len(strDatabasePath)
    3. ' Result is the key identifier
    4. RegSetValueEx Result, "File Path", 0, REG_SZ, strDatabasePath, lngcbData
    am i making a mistake?

  2. #2
    Si_the_geek
    Guest

    Re: RegSetValueEx function

    yep, you need to change it slightly - add a chr(0) to the end (it's how C expects it, and API functions like this are C based).
    VB Code:
    1. lngcbdata = Len(strDatabasePath) + 1
    2. ' Result is the key identifier
    3. RegSetValueEx Result, "File Path", 0&, REG_SZ, strDatabasePath & chr(0), lngcbData

  3. #3

    Thread Starter
    Hyperactive Member abhid's Avatar
    Join Date
    Nov 2001
    Location
    3rd rock from the sun
    Posts
    467
    thanks si_the_geek but still the same problem.

  4. #4
    Si_the_geek
    Guest
    Have you set the variable REG_SZ?

    It should be:
    REG_SZ = &O1

  5. #5

    Thread Starter
    Hyperactive Member abhid's Avatar
    Join Date
    Nov 2001
    Location
    3rd rock from the sun
    Posts
    467
    yes I have.
    Even i am assigning the buffer size of string also.

  6. #6

    Thread Starter
    Hyperactive Member abhid's Avatar
    Join Date
    Nov 2001
    Location
    3rd rock from the sun
    Posts
    467

    Done!

    Its solved...........
    it should be
    VB Code:
    1. RegSetValueEx Result, "Database Path", 0&, REG_SZ, ByVal strDatabasePath, lngcbData
    that byval was causing all the problem!

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