Page 1 of 1
Forum

Welcome to the Tweaking4All community forums!
When participating, please keep the Forum Rules in mind!

Topics for particular software or systems: Start your topic link with the name of the application or system.
For example “MacOS X – Your question“, or “MS Word – Your Tip or Trick“.

Please note that switching to another language when reading a post will not bring you to the same post, in Dutch, as there is no translation for that post!



Share:
Notifications
Clear all

[Solved] Lazarus/Delphi - Writing data files in Program Files directory

1 Posts
1 Users
0 Reactions
1,910 Views
 Hans
(@hans)
Famed Member Admin
Joined: 12 years ago
Posts: 2860
Topic starter  

With the latest Windows versions (at least for 7 and newer), Microsoft decided in their wisdom to make files in a directory in the "C:Program Files" or "C:Program Files (x86)" READ ONLY ... well, for those of us who'd like their program to be portable, this "feature" can be a real pain ...

How do we work around this limitation?

Option 1 - Write in the proper config directory ... 

The function GetAppConfigDir(false); is helpful for that purpose and it works right out of the box ... well, kind-a anyway. The file is NOT stored with your application, which is something you'd like for an app that is suppose to be portable ... (pass the value false for apps)

Option 2 - Set the proper access rights ...

This method has worked for me so far, but I can't guarantee it to work for ever: 

1 - Create a data directory in the application directory, for example:
C:Program Files<your application>data

2 - Right click and change the security settings.
For the group "Users" add the "Full Control" option. As of this point this file is read/write enabled for every user.

For distribution, we now zip the file with the data directory ... unzipping it on a different computer will bring along the access rights ,...


   
ReplyQuote
Share: