Sign in to follow this  
Crazyfool

Vista and running games on it

Recommended Posts

Hi, I have spent too many hours trying to get my game to run on Vista without forcing players to manually choose "Run as Administrator" by removing unnecessary file creation at the start of the game, and replacing all "std::fstream" with "std::ifstream" when I only needed to read the files. The problem really only occurs when the game is installed in the Program Files directory. I don't think I can code it to the point of forcing them to run as admin (and if they're not, have them enter the password or whatever the standard vista option is) - if I can, this will probably solve all my issues. My concern now comes with the issue of 1) Screen shots, 2) interface files (i.e., the positions of menus, hotkeys, toolbar settings, etc). Those are saved at the end of the program or when a player presses PrtSc. I record screenshots purely through directX 9 (I can post the code if you'll be able to tell if its Vista friendly or not). I am not 100% concerned with the others, as I can have buttons (like spells) be stored on the server, and sent on login, as it is not very much memory, probably 10-20 bytes is all I'd need to send. I am also not completely concerned with hotkeys, as this can ALSO be stored on the server, but I'd like to keep it as local as possible. This stuff is saved at the end of the game, when they quit. Thanks for any help, I now hate Vista because of this. I am fortunate that I had a spare Vista lap top sitting around that allowed me to test it easily without constantly sending my game to friends.

Share this post


Link to post
Share on other sites
Use the "home folder" that you are allowed to write in.
Check out SHGetFolderLocation or SHGetKnownFolderIDLis (vista only) functions.
There doesn't seem to be a standard convention yet, some games like to put data in C:/Users/<username>/Documents/My Games, some in C:/Users/<username>/AppData

Share this post


Link to post
Share on other sites
Quote:
Original post by Crazyfool
Thanks for any help, I now hate Vista because of this. I am fortunate that I had a spare Vista lap top sitting around that allowed me to test it easily without constantly sending my game to friends.
Your app is broken if it requires writing to Program Files. The fact that it works on Windows XP is due to most users running with administrator privileges. I was one of the XP users who ran as standard user, so your game would've been broken for me even then.

If you want to work with string paths instead of PIDLs, you can use SHGetFolderPath.

Quote:
Original post by marsong
There doesn't seem to be a standard convention yet, some games like to put data in C:/Users/<username>/Documents/My Games, some in C:/Users/<username>/AppData
Raymond Chen describes the difference here.

Share this post


Link to post
Share on other sites
Using C:\Users\<username> aka %HOMEDRIVE%%HOMEPATH% would solve this problem or you can even go the World of Warcraft solution to the problem and use C:\Users\Public\Games

Share this post


Link to post
Share on other sites
Quote:
Original post by mutex
Your app is broken if it requires writing to Program Files. The fact that it works on Windows XP is due to most users running with administrator privileges. I was one of the XP users who ran as standard user, so your game would've been broken for me even then.

If you want to work with string paths instead of PIDLs, you can use SHGetFolderPath.

Quote:
Original post by marsong
There doesn't seem to be a standard convention yet, some games like to put data in C:/Users/<username>/Documents/My Games, some in C:/Users/<username>/AppData
Raymond Chen describes the difference here.


Well, that seems a bit strong to say. I have never played a game that did not write screen shots to the program folder. Never. I am not saying that they did it wrong, but it pretty much set a precedent for gamers to expect the same functionality. I am sure there are games that save screen shots to other folders, probably now more since Vista has taken on more popularity.

Just look at it from my position - I am only trying to follow what other games have done. No matter how bad the practice, I think its best to keep the convenient things players expect to be consistent. Tab is my auto target, num pad will be auto run, right clicking on a target will attack them, etc. Thats what players expect.

With that being said, I have no other option I just wanted to defend my 'broken' app ;p

Share this post


Link to post
Share on other sites
The problem lies in the fact that Windows XP and Vista use a different security model from Windows '95 which is where the writing data into the Program Files directory convention came into place (when security policies were pitiful if they even existed). The NTFS filesystem has far superior security policies (as compared to Win95) and non-admin users are only allowed free access to a few directories.

You have two options -- you can either write the Users directory using API calls or you can install the game into the root directory (e.g., c:\yourAppName) which is the method that WoW uses if it's not in the Program Files directory.

Personally I hate this as it's very *nix in style but this is not new and can hardly be blamed on Vista -- all of this started with the advent of NT 4.0 and Windows 2000 (not sure about Me but I'm pretty sure it was a GUI overhaul of '95 but either way it's irrelevant at this point). Vista just enforces it more thoroughly.

Share this post


Link to post
Share on other sites
Quote:
Original post by marsong
There doesn't seem to be a standard convention yet, some games like to put data in C:/Users/<username>/Documents/My Games, some in C:/Users/<username>/AppData
If you are on Vista and wish to store data in the user's Documents area, please use the known folder FOLDERID_SavedGames, and not some horrible My-prefixed folder. [smile]

Share this post


Link to post
Share on other sites
Quote:
Original post by Crazyfool
Well, that seems a bit strong to say. I have never played a game that did not write screen shots to the program folder. Never. I am not saying that they did it wrong, but it pretty much set a precedent for gamers to expect the same functionality. I am sure there are games that save screen shots to other folders, probably now more since Vista has taken on more popularity.

Just look at it from my position - I am only trying to follow what other games have done. No matter how bad the practice, I think its best to keep the convenient things players expect to be consistent. Tab is my auto target, num pad will be auto run, right clicking on a target will attack them, etc. Thats what players expect.

With that being said, I have no other option I just wanted to defend my 'broken' app ;p


Sticking with something, anything, just because "that's the way its always been done" is a terrible excuse for anything. The fact that Windows defaulted users to admin privileges for most of its lifespan, allowing ordinary users to write anywhere they please willy-nilly, and that uninformed or lazy devs took advantage of that in the past has left windows with many security attack vectors, as well as system-wide stability issues.

Windows has finally gotten around to doing The Right Thing, and now its up to developers to play along. Its unfortunate, but we should really be blaming the problem (that admin rights were default in the past) rather than the solution (taking them away) -- In reality, its not your app that is broken, but all the others. We certainly shouldn't be compromising security and stability just to allow a loophole for games to write screenshots to their program folder.

Conventions are great and all, but a broken convention just perpetuates flawed practices, entrenching them even deeper -- its best to root them out as early as possible before the "infection" has spread, and consequences are milder.

Share this post


Link to post
Share on other sites

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