Indigo Rose Software

Professional Software Development Tools

 
+ Reply to Thread
Results 1 to 10 of 10
  1. #1
    Join Date
    Apr 2008
    Location
    Florida
    Posts
    17

    Registry.DoesKeyExist problem

    I seem to be having a problem with this registry action.

    I have a line in my code as follows:

    Registry.DoesKeyExist(HKEY_LOCAL_MACHINE, LicenseMainKey)

    This seems to be returning false, even though when I look in the registry, it does exist. The other part of this, is that just opening the registry with regedit seems to solve the problem.

    Can anybody tell me if this is some sort of known issue with this registry action?

  2. #2
    Join Date
    Jan 2001
    Location
    Anderson Island, WA, USA
    Posts
    2,863
    what does LicenseMainKey evaluate to?


    (Click here to contact me)
    Providing Independent Professional Consulting Services for
    IndigoRose products, World Wide.
    Located in -8:00 (-7:00 DST) GMT Timezone (Western United States)

  3. #3
    Join Date
    Apr 2008
    Location
    Florida
    Posts
    17
    LicenseMainKey evaluatets to "SOFTWARE\\CompanyName\\ProductName\\2009\\Licensi ng"

    At first I thought it might be some sort of "permissions" issue, however if I take away the "DoesKeyExist" check, I can succesfully write to that key.

  4. #4
    Join Date
    Jan 2001
    Location
    Anderson Island, WA, USA
    Posts
    2,863
    I dunno weird one.
    if it returns false, then you open up regedit and exit, and then it returns true... very weird.


    (Click here to contact me)
    Providing Independent Professional Consulting Services for
    IndigoRose products, World Wide.
    Located in -8:00 (-7:00 DST) GMT Timezone (Western United States)

  5. #5
    Join Date
    Apr 2008
    Location
    Florida
    Posts
    17
    Yup, weird pretty much describes it.
    But it is a big problem for me.

    If I bypass the "DoesKeyExist" check, and just write to it, it seems to write just fine, but I would much rather see if the key exists first, because that determines if the app is installed in the first place, and I do not want to do the write to the key if the app is not installed.

  6. #6
    Join Date
    Jan 2001
    Location
    Anderson Island, WA, USA
    Posts
    2,863
    I've never had that problem.
    if you can write to it -- try reading the value to see if it's there. end result is you know it if it's there or not.


    (Click here to contact me)
    Providing Independent Professional Consulting Services for
    IndigoRose products, World Wide.
    Located in -8:00 (-7:00 DST) GMT Timezone (Western United States)

  7. #7
    Join Date
    Apr 2005
    Location
    São Paulo, Brazil
    Posts
    2,539
    Do you perform any error checking when you get false from Registry.DoesKeyExist()?

    For example, what do you get when you execute this code:
    Code:
    res = Registry.DoesKeyExist(HKEY_LOCAL_MACHINE, LicenseMainKey);
    if (res == false) then
        error = Application.GetLastError();
        SetupData.WriteToLogFile("Error\tError " .. error .. " (" .. _tblErrorMessages[error] .. ") when searching for registry key '" .. LicenseMainKey .. "'\r\n");
    end
    This could show the exact error code, and display that you are indeed looking where you think you are looking for the key.

    Ulrich

  8. #8
    Join Date
    Apr 2008
    Location
    Florida
    Posts
    17
    When I run the following in my code:

    res = Registry.DoesKeyExist(HKEY_LOCAL_MACHINE, LicenseMainKey);
    if (res == false) then
    error = Application.GetLastError();
    SetupData.WriteToLogFile("Error\tError " .. error .. " (" .. _tblErrorMessages[error] .. ") when searching for registry key '" .. LicenseMainKey .. "'\r\n");
    end


    res returns false, even though the key is there.

    GetLastError() returns 0 (sucess), so there does not appear to be an error in the call.
    I just don't get why it would return false, when the key is there.

  9. #9
    Join Date
    Apr 2005
    Location
    São Paulo, Brazil
    Posts
    2,539
    Hello,

    I suppose that something is not exactly like you are telling us. The best would be if you allow us to have a look at the actual code you are using, by posting the exported project, or a slimmed down version of it where the issue still can be reproduced. If you don't want to make the project available to the public, you can contact some individuals who offer help privately, like Josh. I assume that you don't have an active maintenance contract, or you probably would have already opened a support ticket for this issue in the customer portal.

    Ulrich

  10. #10
    Join Date
    Apr 2008
    Location
    Florida
    Posts
    17
    I found the answer to my problem.
    My problem was in how I created the variable "LicenseMainKey".
    It seems like I had more backslash characters than I needed.
    I am still baffled by the fact that running regedit made the system more tolerant to the extraneous backslashes, but at least I can move forward now.

    Thanks for all your help.

Tags for this Thread

Posting Permissions

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