You should really not be creating files in the Program Files folder any
longer.  All modern software writes files to the users application data
folder.  See the following for references.

http://delphi.about.com/od/kbwinshell/a/SHGetFolderPath.htm

http://stackoverflow.com/questions/471123/accessing-localapplicationdata-equ
ivalent-in-delphi

To get around the issue of users trying to find the folder, add a method to
open the folder inside your program.

ShellExecuteW(Handle,nil,'explorer.exe',PWideChar('"'+Folder+'"'),nil,SW_SHO
W);

Ross.
 
-----Original Message-----
From: Delphi [mailto:[email protected]] On Behalf Of Wilfried
Mestdagh
Sent: Monday, 8 September 2014 5:54 a.m.
To: 'Moderated List for the Discussion of Delphi Programming excluding
Database-related topics'
Subject: RE: ExtractFilePath in Windows Vista

Hi,

So if UAC is 'on' and the application runs 'as administrator' (elevated)
then it save's in the right place?

How can I detect in Delphi that I run as administrator? Then I could set a
warning to the user. If not possible, can I detect if UAC is turned on?

PS: I really do not want to ask a customer to mail me a data file or
configuration file that is placed into
"C:\Users\<username>\AppData\Local\VirtualStore\Program Files\myprogram\.
Also remember that some of these folders are hidden, not all customers are
so computer minded that they can find this. But looking or edit or mail
something from a c:/program files/myprogram/ folder, that is for most of
them possible.  But that is my personal opinion...

--
mvg, Wilfried
http://www.mestdagh.biz
http://www.comfortsoftware.be
http://www.expertsoftware.be


> -----Oorspronkelijk bericht-----
> Van: Delphi [mailto:[email protected]] Namens Sid Gudes
> Verzonden: zaterdag 6 september 2014 7:31
> Aan: 'Moderated List for the Discussion of Delphi Programming excluding
> Database-related topics'
> Onderwerp: Re: ExtractFilePath in Windows Vista
> 
> This is part of the Windows security system that was implemented, I
> believe starting with Windows Vista, but perhaps it started with
> Windows 7.
> 
> To make sure that viruses have a harder time installing malware,
> executables cannot write to Program Files unless they are
> elevated.  Files that are written to Program Files are actually
> placed in another folder, for where see
> http://stackoverflow.com/questions/11348965/where-does-windows-7-put-
> files-saved-to-program-files.
> 
> You can either have users run your program with elevated permissions,
> or, what I think makes more sense, is to create those folders under
> the User folder, not in the ParamStr(0) folder.  This is consistent
> with the current Windows security philosophy.
> 
> You can use SHGetFolderPath with the CSIDL_APPDATA parameter to get
> the User folder.
> 
> 
> At 02:09 PM 9/4/2014, Wilfried Mestdagh wrote:
> >Hi,
> >
> >When I write a program, then it create a few folders in the
> application
> >directory for initialization files and data files. I use therefore
> >AppPath := ExtractFilePath(ParamStr(0));
> >And ForceDirectories(...) to create the folders.
> >
> >This has always worked, also on Windows Vista (32bit and 64bit) and
> later.
> >Now for the first time at a customar it did not worked. The
> directories and
> >files where created but I could not locate where it was (I assume
> somewhere
> >in the user directories).
> >
> >To overcome this problem I copied my executable on another directory
> in the
> >C drive (not program files), then it worked.
> >
> >I once had this problem also in a C# NTService. It was something with
> the
> >execution directory. I solved this, but this is Delphi 7...
> >
> >Maybe ParamStr(0) does not (sometimes) point to the real directory?
> Someone
> >can advice here?
> >
> >Note: This customer is the first customer I met where UAC was still
> on!
> >Something to do with that? (normally everyone has switched this stupid
> thing
> >off...)
> >
> >thx
> >
> >--
> >mvg, Wilfried
> >http://www.mestdagh.biz
> >http://www.comfortsoftware.be
> >http://www.expertsoftware.be
> >
> >_______________________________________________
> >Delphi mailing list
> >[email protected]
> >http://lists.elists.org/cgi-bin/mailman/listinfo/delphi
> 
> _______________________________________________
> Delphi mailing list
> [email protected]
> http://lists.elists.org/cgi-bin/mailman/listinfo/delphi

_______________________________________________
Delphi mailing list
[email protected]
http://lists.elists.org/cgi-bin/mailman/listinfo/delphi


_______________________________________________
Delphi mailing list
[email protected]
http://lists.elists.org/cgi-bin/mailman/listinfo/delphi

Reply via email to