Home » Developing U++ » U++ TheIDE and Library: Releases and ChangeLogs » GetHomeDirectory, GetHomeDirFile in Win32
|
|
Re: GetHomeDirectory, GetHomeDirFile in Win32 [message #10499 is a reply to message #10493] |
Thu, 12 July 2007 21:49 |
|
mirek
Messages: 13980 Registered: November 2005
|
Ultimate Member |
|
|
benoitc wrote on Thu, 12 July 2007 05:02 | Thanks.
BTW, it might be good to update ConfigFile() as well for Windows to be more compliant with Windows path used for application.
Instead of using the EXE directory.
return GetExeDirFile(file);
We can store config file in the "Application Data" Windows directory that belong to the user.
String p = GetHomeDirFile("Application Data\\" + GetExeTitle());
static bool b;
if(!b) {
RealizeDirectory(p);
b = true;
}
return AppendFileName(p, file);
Regards,
Benoit
|
Sure, I was thinking about it too, however, I feel like for most applications in win32 (at least for those I sell to my customers), keeping .cfg in exedir leads to much simpler maintenance (uninstall? delete the folder. broken .cfg? you know where to find it). But perhaps it could be some flag switching the behaviour, with exedir as default?
Mirek
|
|
|
|
|
Re: GetHomeDirectory, GetHomeDirFile in Win32 [message #10728 is a reply to message #10512] |
Wed, 25 July 2007 18:36 |
mrjt
Messages: 705 Registered: March 2007 Location: London
|
Contributor |
|
|
It might be a better idea to use getenv("APPDATA") for application config (equivalent to HOMEDRIVE\HOMEPATH\Application Data) rather than the users root profile directory.
On a slight tangent, I'm going modify FileSel to include links to My Documents(Win32)/Home(Linux) and Desktop as their absence has been annoying me for ages. The safest way I've found to get these paths one windows is (for My Docs):
TCHAR path[MAX_PATH];
HRESULT hr = SHGetFolderPath(NULL, CSIDL_PERSONAL, NULL, SHGFP_TYPE_CURRENT, path);
MDSN page here. Does anyone know of a better way? Has this been done already?
[Updated on: Wed, 25 July 2007 18:37] Report message to a moderator
|
|
|
Re: GetHomeDirectory, GetHomeDirFile in Win32 [message #10729 is a reply to message #10728] |
Wed, 25 July 2007 19:22 |
Zardos
Messages: 62 Registered: April 2007
|
Member |
|
|
mrjt wrote on Wed, 25 July 2007 18:36 | It might be a Does anyone know of a better way? Has this been done already?
|
For my personal requirements I have already written some functions to get the default pathes on windows (including vista) what I have found is to use the values from the registry:
HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVers ion\\Explorer\\User Shell Folders
You are probably interested in the Keys:
"Personal"
"Desktop"
...Of course I would share the code, but all this is just an ugly hack with some very specific funtions.
Basically I have the following funtions for storing configurations:
String GetConfigPath(const char*name, const char *subpath);
inline String UserConfigPath(const char *subpath = NULL) { return GetConfigPath("AppData", AppendFileName(GetExeTitle(), subpath)); }
inline String AllUserConfigPath(const char *subpath = NULL) { return GetConfigPath("Common AppData", AppendFileName(GetExeTitle(), subpath)); }
inline String AppConfigPath(const char *subpath = NULL) { return GetConfigPath("ExeConfigFilePath", subpath); }
inline String UserLocalPath(const char *subpath = NULL) { return GetConfigPath("Local AppData", AppendFileName(GetExeTitle(), subpath)); }
String UserConfigFile(const char *file = NULL, const char* subpath = NULL);
String AllUserConfigFile(const char *file = NULL, const char* subpath = NULL);
String AppConfigFile(const char *file = NULL, const char* subpath = NULL);
String UserLocalFile(const char *file = NULL, const char* subpath = NULL);
... well, probably not useful for you.
Edit: The link you mention is declared: Deprecated... I guess its better to use the registry values, and probably the usual way.
[Updated on: Wed, 25 July 2007 19:25] Report message to a moderator
|
|
|
Re: GetHomeDirectory, GetHomeDirFile in Win32 [message #10737 is a reply to message #10729] |
Thu, 26 July 2007 10:38 |
mrjt
Messages: 705 Registered: March 2007 Location: London
|
Contributor |
|
|
Zardos wrote |
Edit: The link you mention is declared: Deprecated... I guess its better to use the registry values, and probably the usual way.
|
I noticed that too, although it's only depreciated because MS introduced a new non-backwards compatible function in Vista (under Vista the above code is a wrapper for this new method).
Thanks for the tip on registry entries, I suspect that all SHGetFolderPath is doing is reading from these, so I may as well cut out the middle-man .
Cheers,
James
[Updated on: Thu, 26 July 2007 10:40] Report message to a moderator
|
|
|
|
|
|
Goto Forum:
Current Time: Thu May 16 19:12:34 CEST 2024
Total time taken to generate the page: 0.01572 seconds
|