Jump to content
  • Advertisement
Sign in to follow this  
hydroo

windows "home directory"

This topic is 3766 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

Is there a way to get the home directory of the current user in windows. Like /home/xxx in *nix and C:\Users\xxx in vista? Most likely on Win XP too.

Share this post


Link to post
Share on other sites
Advertisement
Yeah this a such a common question that Microsoft actually has an article on this and it's not as simple as it would first appear:

How to write a Windows XP Application that stores user and application data in the correct location by using Visual C++

SUMMARY
Applications work with two types of documents: those that the user creates and those that the application creates. Your applications should use the SHGetFolderPath shell function to retrieve valid folder locations to store data that is specific to the user and the application. This is essential for Windows XP applications to support multiple users who are using the same computer and to enable users to switch quickly.

Share this post


Link to post
Share on other sites
It's more like I need a starting directory to show at the first time, when opening a file/document.

Are these environment variables set on xp and vista?

Share this post


Link to post
Share on other sites
Use the functions. Looking at environment variables and registry entries isn't reliable for this, for a bunch of reasons.

Share this post


Link to post
Share on other sites
Like Colin Jeanne said you can use SHGetFolderPath. This works for XP and Vista. There are a number of pre-defined folders you can get by using this function. It sounds like the one you would want is CSIDL_PROFILE...
Quote:

CSIDL_PROFILE (FOLDERID_Profile)
The user's profile folder. A typical path is C:\Documents and Settings\username

Share this post


Link to post
Share on other sites
many thanks

€: the laughing man - I love Ghost in the Shell - although it's been a while

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!