Help with preference files
Posted: Sun Nov 21, 2010 6:37 pm
I would be grateful if someone could help me please with a problem that I am having with program installation and then reading and
writing to a Preference file.
I have done searches on the forum and on Google and tried various different options and settings, both within my program code and in the
Inno Setup Compiler that I am using to create a setup file, without success. It is the first time I have used a preference file to
save some settings from within my code.
I have read this forum entry...
http://www.purebasic.fr/english/viewtop ... ry#p338746
The program itself is a simple utility program, with 5 saved variable settings in a preference file. When I create the exe and put this in a directory with a default preference file, it all works correctly. However, when I then went on to build a setup file where the exe file and preference file are placed together in the same installed program directory, when the program is started it works fine, apparently reading the default preferences file (there is error checking within the program code for the preference file). However, When I close the program and at this point the variables are saved, another preference file is created in the directory C:\Users\OEM\AppData\Local\VirtualStore\Program Files(x86)\. The program then apparently uses this preference file for subsequent reads and writes.
I have tried various changes of code within the program such as, for the reading and
for the writing, without success. I have also changed various file and folder constants in the setup compiler without any success. Ideally, I am wanting to put a default preference file somewhere it can be accessed by the program and then uninstalled when the user removes the program from their computer.
I am using Windows 7 and the other operating systems the program is intended for are XP and Vista. I have noted a comment made about not using the SetCurrentDirectory() for this purpose and that the preference file should not be in the same directory as the exe file. Any advice or guidance as to where I would look to understand further about reading and writing to preference files and storing them correctly in different versions of Windows would be appreciated.
Thank you, George.
writing to a Preference file.
I have done searches on the forum and on Google and tried various different options and settings, both within my program code and in the
Inno Setup Compiler that I am using to create a setup file, without success. It is the first time I have used a preference file to
save some settings from within my code.
I have read this forum entry...
http://www.purebasic.fr/english/viewtop ... ry#p338746
The program itself is a simple utility program, with 5 saved variable settings in a preference file. When I create the exe and put this in a directory with a default preference file, it all works correctly. However, when I then went on to build a setup file where the exe file and preference file are placed together in the same installed program directory, when the program is started it works fine, apparently reading the default preferences file (there is error checking within the program code for the preference file). However, When I close the program and at this point the variables are saved, another preference file is created in the directory C:\Users\OEM\AppData\Local\VirtualStore\Program Files(x86)\. The program then apparently uses this preference file for subsequent reads and writes.
I have tried various changes of code within the program such as,
Code: Select all
pathtofile.s = GetPathPart(ProgramFilename()) + "Program.prefs"
Code: Select all
SetCurrentDirectory(GetPathPart(ProgramFilename()))
I am using Windows 7 and the other operating systems the program is intended for are XP and Vista. I have noted a comment made about not using the SetCurrentDirectory() for this purpose and that the preference file should not be in the same directory as the exe file. Any advice or guidance as to where I would look to understand further about reading and writing to preference files and storing them correctly in different versions of Windows would be appreciated.
Thank you, George.