Sign in to follow this  

Windows best practices

This topic is 3295 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm looking for some documentation/advice about best practices for developing and installing programs that run under a windows environment. I bought a laptop with Vista the other day and felt like a stone-age developer when I installed Civilization IV (not a new game!) and it automatically added itself to my Vista games folder, showed the game's 'E for everyone' rating and had a picture of the retail box! How the hell does Vista/Civ know to do that? I'm using C++ and Win32, but I imagine most of this is the same for any language. In no particular order: 1. It seems assuming the player is an administrator is no go anymore. This means I install my software to the Program Files(x86) directory (it used to be just Program Files - is there a way to ask windows what the directory is?) and then I put all of the save game files and config data in "<user name>\My Game\"? How do I know the user name? 2. The windows registry never made sense to me. I saved my config file to the directory with my software and I was happy. Uhh. Now I'm saving my config file to "<user name>\My Game\", right? So what's the point of the registry again? 3. I assume I have to register my program with windows somehow. There's that awesome add/remove programs thing that's been in windows for a while. And then now in Vista apparently I can register my program in other ways - tell it my software is a game somehow? Even if I just use install shield or whatever other installer, the question still remains, what's *it* doing to register my program with windows? 3. My DLL files go in the same directory as my executable? 4. Anything else I should be aware of for running happily alongside windows/Vista?

Share this post


Link to post
Share on other sites
The DirectX SDK documentation has a wealth of info just like this. IIRC the topics are organized in the general programming info section.

In general, if you take into account that the user is not likely an admin, Vista behaves (for the most part) like XP.

Machine registry is useful when application/system configuration data needs to be in a centralized place, but unmodifiable by standard users. Per-user registry is also useful, for storing settings that need to be stored somewhere, but not explicitly meant to be modified manually by the user unless absolutely necessary.

An update to Civ IV was released after Vista Game Explorer API became available. There is a simple protocol available to register your own applications to the game menu. This is usually done by the install script, but a game can do the registration process after install, given admin rights are available.

Your other questions are answered in the SDK help file.

Share this post


Link to post
Share on other sites
1. Use SHGetSpecialFolderPath with CSIDL_PROGRAM_FILES. If you're using an installer I would think it would do this sort of thing for you, but I never use them so don't really know.

2. Use SHGetSpecialFolderPath and put your config file in CSIDL_APPDATA. Or you can put settings in the registry. The idea of the registry was that now you have an easily backup-able place to put settings that is also easy for network admins to get to. In practice I don't find it works very well, especially for single-end-user stuff like games. Save game files should probably go to a subdirectory under CSIDL_MYDOCUMENTS.

3. You don't *have* to register anything with Windows. You can if you want. Mostly that means getting your app into Add/Remove programs so it's easier to uninstall. There's some info at http://nsis.sourceforge.net/Add_uninstall_information_to_Add/Remove_Programs but I've never bothered to do this myself so can't vouch for it's accuracy. I vaguelly remember that there's other stuff you can do, but I don't know anything about it and it's all optional.

3(2). Generally yes.

4. The main thing is that your app should work from a non-administrative account. That mostly means that you don't try to write info to any protected places. See SHGetSpecialFolderPath as above. Don't hardcode paths.

Share this post


Link to post
Share on other sites

This topic is 3295 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this