>My path setting inside the app expects a data folder inside the folder containing the EXE.
Well, you rather should change that need instead of looking for a location of the EXE, where this is possible.
There are system functions to determine the AppData folder which is menat for, well, app data. And you don't need a seperate routine for win7, vista and xp, if you use these.
In Inno Setup use the constants to denote sepcific system folders:
{commonappdata} is the folder you will want to install your data. Inno will then use the path depending on the OS.
Your own app should then use a function to determine that path:
Code:
Function GetCommonAppData()
#Define CSIDL_COMMON_APPDATA 0x0023
#Define SHGFP_TYPE_CURRENT 0
Local lcFolder
If Os(5)>='6000'
lcFolder = Addbs(Getenv('ProgramData'))
Else
lcFolder = Space(512)
=SHGetFolderPath(_vfp.HWnd, CSIDL_COMMON_APPDATA, 0, SHGFP_TYPE_CURRENT, @lcFolder)
lcFolder = Addbs(Left(lcFolder,At(Chr(0),lcFolder)-1))
Endif
Return lcFolder
EndFunc
Here you need a branch depending on OS version, because since Vista the SHGetFolderPath is a deprecated system function on the one side, and it's very easy to use Getenv('ProgramData') since Vista on the other side. But that isn't a variable set in XP.
So this function get's you that folder for XP-Win7 and should continue to work in Win8, I had no chance to test that yet.
On the other side, you can also install data into a subfolder of your program folder and use Innos feature to set permissions on folders. Inno has your situation described in it's help, too:
Inno help said:
It is recommended that you avoid using this parameter to grant write access on directories containing program files. Granting, for example, everyone-modify permission on the {app} directory will allow unprivileged users to tamper with your application's program files; this creates the potential for a privilege escalation vulnerability. (However, it is safe to change the permissions on a subdirectory of your application's directory which does not contain program files, e.g. {app}\data.)
So you also may use that way. A subfolder within program files could be a higher security risc, than putting data into CommonAppData, though. Not for the data itself, this is then modifiable and that is needed anyway. But there may be a hack to change parent folder access permissions using the permission inheritance and some security flaw, which would open doors to your applications program files and then to the general program files and other apps as well. This chance is never given for the CommonAppData folder, as that folder is on no child level of the Program Files folder. Maybe that's just my thinking and it's a nightmare, which never will happen. Indeed every thought about permissions is useless, if hackers achieve administrative privileges anyway, but then you could also not care at all about program and data location, and that would surely be careless.
So I would really recommend putting your data into CommonAppData, as that's meant for it.
Bye, Olaf.