forums.silverfrost.com Forum Index forums.silverfrost.com
Welcome to the Silverfrost forums
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

storage path for %ss function

 
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> ClearWin+
View previous topic :: View next topic  
Author Message
Bartl



Joined: 16 Oct 2009
Posts: 58
Location: München

PostPosted: Mon Aug 02, 2010 11:54 am    Post subject: storage path for %ss function Reply with quote

Paul,
if I use the %ss code for save settings to a .ini file, the storage path is different between XP und VISTA/Windows7.
- in XP: c:\windows\??.ini
- in VISTA: c:\Users\Media\AppData\Local\VirtualStore\Windows\??.ini
although the path %systemroot% is equal on both machines with c:\windows.

Is it possible to read out the actual storage path for the .ini file created with %ss under XP and VISTA/Windows7, because i want to read the .ini file without using the %rd, %rf, %rs controls?

Thank you
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 7916
Location: Salford, UK

PostPosted: Tue Aug 03, 2010 11:26 am    Post subject: Reply with quote

ClearWin+ uses the Windows API WritePrivateProfileString to save the data.

According to the Microsoft documentation for WritePrivateProfileString, the file is written to the "Windows" directory in this context because ClearWin+ uses the user supplied "file" to create the filename without its full path.

If this is accurate then you need a way to get at the "Windows" directory for a given operating system.

However, from what you say, the Microsoft documentation is not correct so this needs further investigation.
Back to top
View user's profile Send private message AIM Address
Bartl



Joined: 16 Oct 2009
Posts: 58
Location: München

PostPosted: Tue Aug 03, 2010 1:39 pm    Post subject: Reply with quote

Paul,
thanks for your prompt response.
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 7916
Location: Salford, UK

PostPosted: Tue Aug 03, 2010 4:51 pm    Post subject: Reply with quote

It looks like there is no easy solution to this.

I think that you are going to have to detect the current operating system and then, if it is Vista, find a way to get the VirtualStore path from the registry using CSIDL_LOCAL_APPDATA.

At this end the best solution would be for me to modify %ss so that you could supply the full path in your program.
Back to top
View user's profile Send private message AIM Address
LitusSaxonicum



Joined: 23 Aug 2005
Posts: 2388
Location: Yateley, Hants, UK

PostPosted: Tue Aug 03, 2010 6:15 pm    Post subject: Reply with quote

Although the %ss function looks convenient, for full control you need to manage persistent program settings yourself.

INI files are the way things used to be done, manipulating entries in the registry is the new way. However, INI files are much more convenient than the registry, and if you mess them up, they result is easier to fix - not least because INI files can be readable with a text editor, and nothing else relies on them.

The problem is - where should INI files be located? Presumably, %ss thinks they should be put into the standard Windows folder. There is a lot to be said for putting it in the \Programs\xxxx folder - or the folder where the program in question is installed. Clearwin has a couple of lovely routines for finding where that is - they cope with a user who has moved the program folder or even renamed the program itself.

You use GET_PROGRAM_NAME@ to get the path and program name into a longish character variable. Now you need to get rid of the "xxx.exe" from the right-hand end of it, and you can find that with any one of a number of command line parsing routines in FTN95, or work it out for yourself by finging the rightmost "\" character. What is left is the path to where the program is stored. An INI file there is always going to be in the "right place". If you are confident that no-one will rename the EXE, you can skip finding the program name, because you already know it.

This method is also useful for connecting to CHM help files installed in the program folder.

Experience tells me that routines for reading INI files need to be robust, and capable of coping with errors introduced by users opening the files and modifying their contents...

Eddie
Back to top
View user's profile Send private message
JohnHorspool



Joined: 26 Sep 2005
Posts: 270
Location: Gloucestershire UK

PostPosted: Tue Aug 03, 2010 9:33 pm    Post subject: Reply with quote

I agree with Eddie, manage the INI yourself without using %ss.

I use the environmental variables HOMEDRIVE and HOMEPATH to determine a directory location for the INI file. The values of these variables are easily found with getenv@. The code works fine for all versions of windows.
Back to top
View user's profile Send private message Visit poster's website
Sebastian



Joined: 20 Feb 2008
Posts: 177

PostPosted: Wed Aug 04, 2010 7:21 am    Post subject: Reply with quote

VirtualStore is the shadow directory that receives writes from non-admin privileged users. As far as I know you should be perfectly fine to still read the file (VirtualStore\Windows\xyz.ini) using the %systemroot%\xyz.ini qualifier.
Back to top
View user's profile Send private message
Bartl



Joined: 16 Oct 2009
Posts: 58
Location: München

PostPosted: Wed Aug 18, 2010 3:34 pm    Post subject: storage path for %ss function Reply with quote

thank you very much for your help.
I think the best and simplest way is to use the %systemroot%.

Bartl
Back to top
View user's profile Send private message
Bartl



Joined: 16 Oct 2009
Posts: 58
Location: München

PostPosted: Wed Aug 18, 2010 3:35 pm    Post subject: storage path for %ss function Reply with quote

Thank you very much for your help.
I think the best and simplest way is to use the %systemroot%.

Bartl
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> ClearWin+ All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group