How to get path to a INI-file in Vista?
-
I have an application that, under the previous operating systems, store application data in a INI file located in the Windows directory. To make customer support easier, I've got a link in the application about box that link to and open the INI file in a text editor. Now, under Windows Vista, the installation application writes some data into the INI file located in the Windows directory, but when the application is reading/writing to the INI file the one in the Windows directory is untouched and a copy of the file is being stored in a windows directory equivalent found in a subfolder in the user folder. Is there a way to get the path to the copy of the INI file located in the user folder? Right now I simply use GetWindowsDirectory + "\\" + "filename.ini" and ShellExecute that. :) /Jonas
-
I have an application that, under the previous operating systems, store application data in a INI file located in the Windows directory. To make customer support easier, I've got a link in the application about box that link to and open the INI file in a text editor. Now, under Windows Vista, the installation application writes some data into the INI file located in the Windows directory, but when the application is reading/writing to the INI file the one in the Windows directory is untouched and a copy of the file is being stored in a windows directory equivalent found in a subfolder in the user folder. Is there a way to get the path to the copy of the INI file located in the user folder? Right now I simply use GetWindowsDirectory + "\\" + "filename.ini" and ShellExecute that. :) /Jonas
I asked the shell team this, and their answer was no, there's no way to say "if this file were put somewhere else due to virtualization, where would it go?" The real answer is to fix your code so it doesn't write to the Windows directory, that way non-admins on all OSes can use it.
--Mike-- Visual C++ MVP :cool: LINKS~! Ericahist | PimpFish | CP SearchBar v3.0 | C++ Forum FAQ Ford, what's this fish doing in my ear?
-
I asked the shell team this, and their answer was no, there's no way to say "if this file were put somewhere else due to virtualization, where would it go?" The real answer is to fix your code so it doesn't write to the Windows directory, that way non-admins on all OSes can use it.
--Mike-- Visual C++ MVP :cool: LINKS~! Ericahist | PimpFish | CP SearchBar v3.0 | C++ Forum FAQ Ford, what's this fish doing in my ear?
-
Thanks for you reply. I decided to check if Vista i running, if it is, I try access with...
getenv("LOCALAPPDATA") + "\VirtualStore\Windows\" + sIniName
..and if that exists I used it. Otherwise I use the file found in the Windows folder. :doh:Try also using
CSIDL_WINDOWS
. Regards, Paresh. -
Try also using
CSIDL_WINDOWS
. Regards, Paresh.Thanks for the tip, but I'm pretty certain that CSIDL_WINDOWS returns the %SYSTEMROOT% variable which is set to e.g. C:\WINDOWS also on a Vista system. I assume, this is also what the regular GetWindowsDirectory function outputs. Nasty, nasty virtualization. /Jonas
-
I have an application that, under the previous operating systems, store application data in a INI file located in the Windows directory. To make customer support easier, I've got a link in the application about box that link to and open the INI file in a text editor. Now, under Windows Vista, the installation application writes some data into the INI file located in the Windows directory, but when the application is reading/writing to the INI file the one in the Windows directory is untouched and a copy of the file is being stored in a windows directory equivalent found in a subfolder in the user folder. Is there a way to get the path to the copy of the INI file located in the user folder? Right now I simply use GetWindowsDirectory + "\\" + "filename.ini" and ShellExecute that. :) /Jonas
Replace your call to GetWindowsDirectory() with a call to SHGetFolderPath(). Pick the appropriate flags such as CSIDL_LOCAL_APPDATA | CSIDL_FLAG_CREATE, etc. to fine tune which of the user's paths you want. Hope this helps, Chris
Author of The Career Programmer and Unite the Tribes www.PracticalStrategyConsulting.com