Registry calls return wrong values - how to fix?

Here is the code used to open the key (all the variations shown produce the same behaviour)
bool Win32_OpenKey( const HKEY uPlaceInRegistry, HKEY& xKey, const char* const szKeyName, const bool bReadOnly = false )
// SE: make sure key exists
// SE - NOTE: this is deprecated. it worked fine, but suddenly doesnt :(
// so i have replaced it with the following line
//const bool bOpened = RegOpenKey( uPlaceInRegistry, szKeyName, &xKey ) == ERROR_SUCCESS;
const bool bOpened = RegOpenKeyEx( uPlaceInRegistry, szKeyName, 0,
bReadOnly ? KEY_QUERY_VALUE : KEY_ALL_ACCESS, &xKey ) == ERROR_SUCCESS;
bool bCreated = false;
if( !bOpened )
// SE - NOTE: this is deprecated. it worked fine, but suddenly doesnt :(
// the Licensor will create keys except in the case where we upgrade a user from
// an old license... so now using the Ex version in hopes it magically works.
//bCreated = RegCreateKey( uPlaceInRegistry, szKeyName, &xKey ) == ERROR_SUCCESS;
DWORD uDisposition = -1;
bCreated = ( RegCreateKeyEx( uPlaceInRegistry, szKeyName, 0, 0,
REG_OPTION_NON_VOLATILE, bReadOnly ? KEY_QUERY_VALUE : KEY_ALL_ACCESS,
0, &xKey, &uDisposition )
== ERROR_SUCCESS );
return bOpened || bCreated;
Here is where the values are queried.
unsigned int uMagic = 0;
unsigned long uType = 0xFFFFFFFF;
unsigned long uSize = sizeof( unsigned int );
//long err = RegGetValue( xKey, 0, "Magic", RRF_RT_DWORD, &uType, &uActivated, &uSize );
uType = REG_DWORD;
long err = RegQueryValueEx( xKey, "Magic", 0, &uType, reinterpret_cast< LPBYTE >( &uMagic ), &uSize );
if( (err == ERROR_SUCCESS) && ( uType == REG_DWORD ) && ( uSize == sizeof( unsigned int ) ) )
unsigned long long ullReadStartDate = 0;
uSize = sizeof( unsigned long long );
err = RegGetValue( xKey, 0, "Number", RRF_RT_QWORD, &uType, &ullReadStartDate, &uSize );
if( (err == ERROR_SUCCESS) && ( uType == REG_QWORD ) && ( uSize == sizeof( unsigned long long ) ) )
The values that are returned do not match the registry.
In fact the values returned are values that we never would have written either. The zero is fishy because maybe it indicates bad behaviour. The messed up time_t value is even more confusing... it comes from a more than 30 days ago, which is around the time
when I first started working on this code.
To make a guess I am getting back an ancient version of the key values which is somehow preserved and accessible but can not be seen in regedit. I have no idea why this is suddenly happening either - this code (before my commented changes were made) worked
exactly as expected for a few weeks now.
Slightly unrelated but it also seems that a standard user can not write to HKCU in our repeatable tests. This seems slightly crazy as well... should I just not be using the registry? It never seemed like a good idea, but I have done it to try and fit the
platform way of doing things after hitting lots of problems with naive use of files...

thanks for the tips. will probably come in handy in the future. :)
it turned out to be permissions and bad documentation in my case. the virtual store thing was not writing to where the docs say it should, and so something was lingering somewhere i couldn't find in the right place under any of the top level registry keys.
maybe there is some other place where it has gone in the registry that i am just not finding the documentation for...
my ultimate fix was to use a file in ProgramData :)
I figured I'd try and do it 'the MS way' and use the registry. what a terrible idea that turned out to be, since I guess its no longer the MS way given how riddled with backwards compatibility hacks it seems to be...

Similar Messages

  • Recently loaded Lion on my laptop and now my computer crashes often. Black screen and keyboard lights up. Any ideas on what's wrong and how to fix this?

    Recently loaded Lion on my laptop and now my computer crashes often. Black screen and keyboard lights up. Any ideas on what's wrong and how to fix this?

    Everytime this happens Ihave to power down and restart! Any ideas would be appreciated!

  • I just got a notice to update my firefox to 4.0 and when I downloaded the new software it indicated: that I can't open the application "Firefox" because it is not supported on this architecture. Any ideas about what might be wrong and how to fix it?

    I just got a notice to update my firefox to 4.0 and when I downloaded the new software it indicated: that I can't open the application "Firefox" because it is not supported on this architecture. Any ideas about what might be wrong and how to fix it?

    Firefox 4 requires at least OS X 10.5 and an Intel Mac. There is a third party version of Firefox 4 that runs on OS X 10.4/10.5 and PPC Macs, for details see http://www.floodgap.com/software/tenfourfox
    If you prefer, you can get the latest version of Firefox 3.6 from http://www.mozilla.com/en-US/firefox/all-older.html

  • I have a 11/2 inch line on my 1st gen iPad. Any ideas on what's wrong and how to fix? Appreciate any replies.

    Have a 11/2 inch wide black,sometimes white bar on screen. Any ideas on what's wrong and how to fix? It's a first gen iPad. Would appreciate any replies. Thanks

    Hi Chuckfrombc,
    Based on your description, it sounds like there may be a hardware issue with your display. You may want to consider taking it in for evaluation and service; you may find the following page helpful (if you are not located in the United States, make sure to select your correct country from the dropdown):
    Service Answer Center - iPad
    http://support.apple.com/kb/index?page=servicefaq&geo=United_States&product=ipad
    Regards,
    - Brenden

  • Woke up to my iPhone 4 being completely blank. I've tried restarting and resetting it as well as charging it and plugging into my computer. Can anyone shed some light as to what may be wrong or how to fix it? Thanks

    Woke up to my iPhone 4 being completely blank. I've tried restarting and resetting it as well as charging it and plugging into my computer. Can anyone shed some light as to what may be wrong or how to fix it? Thanks

    Hello there, Kyle.Kuz.
    The following Knowledge Base article that provides some helpful pointers to help resolve your issue is:
    iPhone: Hardware troubleshooting
    http://support.apple.com/kb/TS2802
    Specifically:
    Will not turn on, will not turn on unless connected to power, or unexpected power off
    Verify that the Sleep/Wake button functions. If it does not function, inspect it for signs of damage. If the button is damaged or is not functioning when pressed, seek service.
    Check if a Liquid Contact Indicator (LCI) is activated or there are signs of corrosion. Learn about LCIsand corrosion.
    Connect the iPhone to the iPhone's USB power adapter and let it charge for at least ten minutes.
    After at least 15 minutes, if:
    The home screen appears: The iPhone should be working. Update to the latest version of iOS if necessary. Continue charging it until it is completely charged and you see this battery icon in the upper-right corner of the screen . Then unplug the phone from power. If it immediately turns off, seek service.
    The low-battery image appears, even after the phone has charged for at least 20 minutes: See "iPhone displays the low-battery image and is unresponsive" symptom in this article.
    Something other than the Home screen or Low Battery image appears, continue with this article for further troubleshooting steps.
    If the iPhone did not turn on, reset it while connected to the iPhone USB power adapter.
    If the display turns on, go to step 4.
    If the display remains black, go to next step.
    Connect the iPhone to a computer and open iTunes. If iTunes recognizes the iPhone and indicates that it is in recovery mode, attempt to restore the iPhone. If the iPhone doesn't appear in iTunes or if you have difficulties in restoring the iPhone, see this article for further assistance.
    If restoring the iPhone resolved the issue, go to step 4. If restoring the iPhone did not solve the issue, seek service.
    Thanks for reaching out to Apple Support Communities.
    Cheers,
    Pedro D.

  • Statvfs returns wrong values

    Hi,
    I am developing a program the will check for disk space (used,blocks, available ...) and i am using the statvfs.h file.
    When tested with small capacity disks (~5G) it works fine (compared to df -k).
    When tested with large capacity disks (~400G) it returns wrong values(compared to df -k).
    I am using f_bavail and i am casting from fsblkcnt_t to integer/long.
    Please help.
    Thanx R.

    Thanks for your answer.
    I have discovered that it (statvfs.h) doe's not work with vxfs, only with ufs.
    I am using Veritas Cluster Server.
    Any chance of an answer ??
    thanks,
    R.

  • My ipod had a full battery but when i took it off charge and put my earphones in it it went completley dead and hasnt come back on. Can anybody tell me what is wrong and how to fix it?

    my ipod had a full battery but when i took it off charge and put my earphones in it, it went completly dead and hasnt come back on.  Can anybody tell me what is wrong and how to fix it?

    Try here to fix it.  I doubt that you will ever find out why it did that.
    iPod touch: Hardware troubleshooting

  • Still running adobe cs2 on leopard. but now get unexpected quit msg. and wont launch. any chance that when i installed then uninstalled GENIEO yesterday something went wrong? how to fix? can i reinstall cs2 from original discs? by stephenftlaud

    still running adobe cs2 on leopard. but now get unexpected quit msg. and wont launch. any chance that when i installed then uninstalled GENIEO yesterday something went wrong? how to fix? can i reinstall cs2 from original discs? bystephenftlaud

    Hi,
    Could be many things, we should start with this...
    "Try Disk Utility
    1. Insert the Mac OS X Install disc, then restart the computer while holding the C key.
    2. When your computer finishes starting up from the disc, choose Disk Utility from the Installer menu at top of the screen. (In Mac OS X 10.4 or later, you must select your language first.)
    *Important: Do not click Continue in the first screen of the Installer. If you do, you must restart from the disc again to access Disk Utility.*
    3. Click the First Aid tab.
    4. Select your Mac OS X volume.
    5. Click Repair Disk, (not Repair Permissions). Disk Utility checks and repairs the disk."
    http://docs.info.apple.com/article.html?artnum=106214
    Then try a Safe Boot, (holding Shift key down at bootup), run Disk Utility in Applications>Utilities, then highlight your drive, click on Repair Permissions, reboot when it completes.
    (Safe boot may stay on the gray radian for a long time, let it go, it's trying to repair the Hard Drive.)
    If perchance you can't find your install Disc, at least try it from the Safe Boot part onward.
    Open Console in Applications>Utilities & see if there are any clues or repeating messages when trying to open CS2.

  • Still running adobe cs2 on leopard. but now get unexpected quit msg. and wont launch. any chance that when i installed then uninstalled GENIEO yesterday something went wrong? how to fix? can i reinstall cs2 from original discs?

    still running adobe cs2 on leopard. but now get unexpected quit msg. and wont launch. any chance that when i installed then uninstalled GENIEO yesterday something went wrong? how to fix? can i reinstall cs2 from original discs?

    Hi,
    Could be many things, we should start with this...
    "Try Disk Utility
    1. Insert the Mac OS X Install disc, then restart the computer while holding the C key.
    2. When your computer finishes starting up from the disc, choose Disk Utility from the Installer menu at top of the screen. (In Mac OS X 10.4 or later, you must select your language first.)
    *Important: Do not click Continue in the first screen of the Installer. If you do, you must restart from the disc again to access Disk Utility.*
    3. Click the First Aid tab.
    4. Select your Mac OS X volume.
    5. Click Repair Disk, (not Repair Permissions). Disk Utility checks and repairs the disk."
    http://docs.info.apple.com/article.html?artnum=106214
    Then try a Safe Boot, (holding Shift key down at bootup), run Disk Utility in Applications>Utilities, then highlight your drive, click on Repair Permissions, reboot when it completes.
    (Safe boot may stay on the gray radian for a long time, let it go, it's trying to repair the Hard Drive.)
    If perchance you can't find your install Disc, at least try it from the Safe Boot part onward.
    Open Console in Applications>Utilities & see if there are any clues or repeating messages when trying to open CS2.

  • On Firefox stage.stageWidth stage.stageHeight return wrong values

    Hello,
    I have a problem on firefox windows 8, stage.stageWidth and stage.stageHeight return wrong values,
    swfobject.embedSWF("mySwf.swf", "mySwf", "500", "500", "14.0.0","expressInstall.swf", flashvars, params, attributes);
    on ie, Chrome stage.stageWidth and stage.stageHeight return 500
    on iFirefox stage.stageWidth and stage.stageHeight return 750 and my animation is smaller (66%)
    Thanks

    In order to target iPhone 5 you need to use AIR 3.5 beta or AIR 3.4
    pointing to iOS 6 SDK. Be sure to include the [email protected] to
    trigger the iPhone 5 size. In other words, the app has to be built
    targeting the iOS 6 SDK and have the new default png to trigger the full
    size on the iPhone 5.
    AIR 3.5 beta includes the bits that to target iOS 6 SDK, but you can
    target iOS 6 with AIR 3.4 by using the external SDK path in the package
    ANE prompt in FB 4.6
    http://labs.adobe.com
    iBrent

  • When orientation change and soft keyboard is activated, return wrong value

    Hello,
    in a View, when the orientation change and the soft keyboard is activated, this.navigator.height return wrong value.
    systemManager.stage.addEventListener(StageOrientationEvent.ORIENTATION_CHANGE, orientationChangeHandler);
    public function orientationChangeHandler(event:StageOrientationEvent):void {
    inp.text=String(this.navigator.height);
    thanks.

    Can you attach a simple sample application that demonstrates this?  What device are you seeing this issue on?

  • NI PCI-6602: semi-period measurement stops unexpectedly or returns wrong values

    Hi,
    Using an NI PCI-6602 card we try to measure the semi-periods of a digital signal.
    In "continuous sampling mode", 10 samples are collected in the buffer and then are read
    out.
    Up to 6 counters on this card are sampling the same signal in our testing configuration.
    Here we found these issues:
    1. Failure
    In principle, the measurement runs correctly, but one or more counters sporadically may
    suffer a complete failure. I.e. these counters don't provide samples anymore.
    Only after stopping and restarting the assigned task, a failed counter works again.
    Apparently, a counter failure is most likely to happen when
        - the sampled signal "changes", i.e. when the pulse width of the signal changes,
        - or when the computer load is high, e.g. when opening a window of another application.
    Every counter occasionally failed, but the issue was found very often at counter 1 of
    the PCI-6602 card, if we used counters 0 through 5 in parallel.
    Using another PCI-6602 card, the failures happened preferably on counters labeled "near"
    number 5.
    2. Wrong values
    Occasionally the "interpretation" of the sampled values changes, i.e. the length of the
    "high level" period is returned, where the "low level" period length should be given, and
    vice versa.
    This is our task configuration:
    Configuration done with MAX:
    Signal input range:    2 usec - 2 sec
    Custom Scaling:        None
    Sample mode:        continuous
    Buffer size:        10 Samples
    In addition these calls are made:
    ret = DAQmxSetDigEdgeArmStartTrigSrc( task->mHandle, <use the same terminal as is used for
    the signal to be measured>);
    ret = DAQmxSetArmStartTrigType( task->mHandle, DAQmx_Val_DigEdge);
    ret = DAQmxSetDigEdgeArmStartTrigEdge( task->mHandle, DAQmx_Val_Rising);
    ret = DAQmxSetCISemiPeriodStartingEdge( task->mHandle, <the channel>, DAQmx_Val_Falling);
    Best regards
    Manfred

    Hi Manfred7,
    did you already test this behaviour with a simple example from us?
    Just go through the example database and try the examples there.
    These examples should work. 
    If it works, there is a problem with your programm.
    If it won't work, please tell me more about your software:
    - Version
    - DAQmx Version ,...
    best regards
    Dippi 

  • IPad audio  output is not working properly, except on Siri. Any ideas on what is wrong and how to fix it?

    iPad audio output does not work, except for on Siri. The mute button is not on, and the volume buttons have no effect/ don't work (unless Siri is open). I have reset the iPad, tried iOS7 and iOS8 resets, which didn't help. The audio output mostly works when headphones are out in, but has a tendency to cut out from time to time. Without headphones, Audio might start working again briefly from time to time, but most the time it doesn't.  Any ideas on what is wrong with it and how to fix it?
    my iPad is a 3rd gen, 16GB wifi only model, if that helps
    I did take it to an Apple Store, but the inncorrectly insisted that my speaker was bust and it would cost £250 to replace the whole iPad!

    Godly19 wrote:
    iPad audio output does not work, except for on Siri. The mute button is not on, and the volume buttons have no effect/ don't work (unless Siri is open). I have reset the iPad, tried iOS7 and iOS8 resets, which didn't help.
    iOS 8 isn't even out yet. If you are running iOS 8, I assume you are a developer and if you are, you are in the wrong forum to try to get help. If you are not a developer and you're running iOS 8, maybe that's why you are having problems on the iPad.
    The audio output mostly works when headphones are out in, but has a tendency to cut out from time to time. Without headphones, Audio might start working again briefly from time to time, but most the time it doesn't.  Any ideas on what is wrong with it and how to fix it?
    The type that I made bold doesn't make sense. Is this a typo and you mean that " headphones are not in"?
    I did take it to an Apple Store, but the inncorrectly insisted that my speaker was bust and it would cost £250 to replace the whole iPad!
    And you know they are incorrect because you get sound here and there from time to time? That fact doesn't prove that something isn't working correctly inside. You could very well have a bad connection inside the device causing this, but somehow you seem to know that's not the case.

  • My photoshop 10 has stopped working  is there a telephone number for support that I can call to find out how to fix the problem???

    My photo shop 10 program has stopped working.  Is there a telephone number that I can call for support to find out how to fix the problem???Jenny

    Please read this (in particular the section titled "Supply pertinent information for quicker answers"):
    http://forums.adobe.com/docs/DOC-2325
    http://blogs.adobe.com/crawlspace/2012/07/photoshop-basic-troubleshooting-steps-to-fix-mos t-issues.html

  • Datasocket return wrong value

    Hello Everyone:
    I am using datasocket to communicate with an opc server.I built a quite simple vi to test the communicaion as you see in the picture.If I highlight the execution I got the right return value( a boolean type indicator),but I run it normally I get the wrong value.The quality of the datasocket read vi display 0.Meanwhile if I add a while loop outside the datasocket read vi,then I get the right value again.I only want to read the opc tag once,do not want to add the while loop in this vi.What should I do?please help me.Thank you very much!

    你先尝试在DataSocket read vi的输入节点加入延时(根据实际应用调节下延时长短)。
    Li Yi

Maybe you are looking for