Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can't find my key in the registry Windows 7 1

Status
Not open for further replies.

OrthoDocSoft

Programmer
May 7, 2004
291
US
Folks,

I installed my app on a windows 7 (32 bit) laptop, and it writes about 30 values to the registry. But when I look under HK_Local_Machine/SOFTWARE, where I write to, I can't find my keys anywhere. But when I close the app and fire it up again, the app opens as though the registry items are there.

Another Windows 7 minitower that I also just got shows the keys just fine, just like they were in Windows XP...

Can anyone figure this out?

Thanks,

Ortho

[lookaround] "you cain't fix 'stupid'...
 
There are lots of things at work here, primarily things like whether or not UAC is enabled, and whether the program runs elevated.

It seems clear though that your program doesn't have a manifest declaring it Vista Aware (Win 6.x aware) so it is having an appcompat shim applied when it runs.

HKLM is protected. If a Vista Aware process tries to write here unelevated it gets a security exception. If a legacy application runs here the system jollies it along and redirects the write to a virtualized location in the user's HKCU hive.

Applications are not supposed to write to HKLM. Changes there are considered administrative in nature. If an application requires per-machine values there your installer should write them, and if necessary change the security on the keys.

Generally applications should stop using the registry for settings. Try an INI, config, etc. file for this instead.
 
Wow.

Dilletante, you have taught me sooooooo much and I am indebted to you greatly. But my app writes its settings to the registry, and I really don't want to reinvent the wheel when I am 99% there. But I WILL practice what you are saying about using INI and config in the future. And maybe that's an upgrade I can put in ver 2.0.

In the meantime, can you give me a simple fix that lets me be able to write to HKLM, and then "see" it when I run regedit, like is the case on ALL my other machines, including a brand new minitower with the same OS? Like I said, I think I AM writing something somewhere, I just need to be able to see it from time to time.

Thanks,

[lookaround] "you cain't fix 'stupid'...
 
Dilettante,

I looked into UAC and basically turned it off. That fixed the problem. I will try to understand more about what you have said, and I will try to look into INI and config.

Thank you, sincerely,

Star.

Ortho

[lookaround] "you cain't fix 'stupid'...
 
There really isn't a fix for this, turning off UAC is a hazard to you and the entire Internet.

As I suggested above, writes to HKLM are considered administrative actions, not for user programs.

You're probably using API calls. It can be pretty simple to write a static module with a few Public functions in it that do the same thing, have the same names and parameters, but write to and read from an INI file. The only "trick" is that you need your installer to create the INI file or at least a common folder that it makes read/write for all users.

Then you can just remove the Declare statements for the API calls and slop in your Reg-to-INI shim module.
 
Dilettante,

I'm practicing writing to INI files already because of you. And I was looking up an api call:

GetPrivateProfileString() and found this in the MSDN:

This function is provided only for compatibility with 16-bit Windows-based applications.Applications should store initialization information in the registry.

Any comments? Is this old-school thinking?

[lookaround] "you cain't fix 'stupid'...
 
Yep, they haven't updated those articles and won't.

While Vista was in public beta they strongly suggested moving away from registry use and back toward .ini, .config, etc. settings files. It had more than a few people chuckling over comments like the one you pointed out.

The response from Microsoft was that they really hate the INI format and want people to use XML config file, because that's the whizzy format du dix ans. But they said INI is better than the registry for most applications, because otherwise people will keep tripping over things like registry security - and mess up their LUA story.
 
Yes but if you want your program to always start when the computer starts (or in the background) and make it difficult for ordinary users to remove this feature without authorisation, you have make your app write to the registry every time your app is started - don't you?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top