Cannot access INI files in "Program Files"

I wrote this application in C ++, which should check the INI file ("preference.ini") and ultimately change it (for example, if the user no longer wants to see the input form). I created it in WinXP and it works fine on the system where I compiled it (in many places, including "Program Files").

Problem:

  • In Win 7, it works fine if I put the full program folder under "C": \ "(for example," C: \ MyProgram "), but if I put it in" C: \ Program Files (x86) \ MyProgram ", it just extracts some mysterious data (values ​​are not present in my INI file). When I change some settings and save them to a file, it (apparently) saves the changes (do not get errors, but there are no changes when I go and open the file .. .
  • I had a similar problem with a system with a different WinXP system (and not with the one where I compiled it).

I used 'getcwd' to determine the path at runtime, and I made sure it was right, even in the "Program Files (x86)" section:

char currentPath[MAXPATH];
getcwd(currentPath, MAXPATH);
std::string licensePath(currentPath);
licensePath.append("\\dat\\preference.ini");'

Any ideas? Thanks in advance for your help.

+3
4

, @Kirill - Win7 Program Files, (Run as Administrator). , , Progam.

: ( ), - Program Files.

AppData. , (Vista/Win7) %appdata%.

, SHGetFolderPath CSIDL_APPDATA ( ) CSIDL_COMMON_APPDATA ( ).

+8

, Windows . . , INI <root>\Users\<User_name>\AppData\Local\VirtualStore.

+3

, licensePath: getcwd() + "\\dat\\preference.ini" , .

( ) , licencePath, .

0

, , ,

http://msdn.microsoft.com/en-us/library/ee419001(VS.85).aspx

, -

An attempt to create or write a file or directory under a folder that does not grant write permission to the process will fail in Windows Vista if the application does not have administrative privileges. If your 32-bit game executable is running outdated because it does not declare the requested runlevel, its write operations will succeed, but they will be virtualized as described in the section “UAC Compatibility with Older Games” later in this article.

0
source

Source: https://habr.com/ru/post/1753467/


All Articles