Is there possible to run CFile::Open in order to write a text file, inside C:\Program Files\ location, with administrator rights, even the application who call this are not started with administrator rights ?
But I suggest to rethink your request. An application should not modify data in the Program Files directory tree. That should be only modified by installation and update processes. Windows provides common directories for application specific data (shared and per user).
I have used Visual C++ for many years without trouble.
But in the last few days, an automatic upgrade came: it shows a MessageBox that says "One-way upgrade. Visual Studio will automatically make functional changes to the following projects in order to open them. ...".
With one of my projects (called 'dragclip_vc'), today, however often I open it and look in it and close it, the new upgrade system shows and needs attention, every time I open that project, and it does not preserve the display of opened files. Please how can I stop that from happening? (I know that the automatic upgrade needs doing once for each of my projects.)
(Another of my projects (called 'makeobj_vc') auto-upgraded correctly and did not ask again for upgrading, and it preserves the display of opened files.)
dragclip_vc is a very small project; all that it does is that if I drag a file into it from a directory display, it puts that file's full pathname in the Windows clipboard. It is useful.
makeobj_vc is a big project.
The '_vc' on the ends of their names means "for Visual C++"; it is to distinguish from old versions that I had written for Borland C.