The Wiert Corner – irregular stream of stuff

Jeroen W. Pluimers on .NET, C#, Delphi, databases, and personal interests

  • My badges

  • Twitter Updates

  • My Flickr Stream

  • Pages

  • All categories

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 2,915 other followers

InnoSetup where the *AppData constants point to

Posted by jpluimers on 2017/11/08

The paths are on a standard Windows 7 x64 machine installed on the C: drive. More recent versions of Windows should use the same place.

I’ve not been able to verify this in a domain situation with roaming profiles and redirected folder paths. If anyone has info on that, please let me know.

Anyway, I’ve made some the constants into a table:

Inno Setup constant
Windows 7 directory KNOWNFOLDERID
CSIDL (<= Vista)
[WayBack] ([WayBack])
Environment variable
commonappdata C:\ProgramData FOLDERID_ProgramData CSIDL_COMMON_APPDATA ALLUSERSPROFILE System.Environment.SpecialFolder.CommonApplicationData
localappdata C:\Users\<UserName>\AppData\Local FOLDERID_LocalAppData CSIDL_LOCAL_APPDATA LOCALAPPDATA System.Environment.SpecialFolder.LocalApplicationData
userappdata C:\Users\<UserName>\AppData\Roaming FOLDERID_RoamingAppData CSIDL_APPDATA APPDATA System.Environment.SpecialFolder.ApplicationData

One day I might find time to make this table more complete.

Until then, the code is somewhere around theses pieces of code:

    • function GetRealShellFolder(const Common: Boolean; const ID: TShellFolderID; ReadOnly: Boolean): String;
      • FolderIDs: array[Boolean, TShellFolderID] of Integer = (
        { User }
        { Common }
    • FolderConsts: array[Boolean, TShellFolderID] of String =
      (('userdesktop', 'userstartmenu', 'userprograms', 'userstartup',
      'sendto', 'fonts', 'userappdata', 'userdocs', 'usertemplates',
      'userfavorites', 'localappdata'),
      ('commondesktop', 'commonstartmenu', 'commonprograms', 'commonstartup',
      'sendto', 'fonts', 'commonappdata', 'commondocs', 'commontemplates',
      'commonfavorites', 'localappdata'));
    • TShellFolderID = (sfDesktop, sfStartMenu, sfPrograms, sfStartup, sfSendTo, sfFonts, sfAppData, sfDocs, sfTemplates, sfFavorites, sfLocalAppData);

Note that the installer usually should not fiddle with localappdata or userappdata: that’s the work of the application itself; the installer should use commonappdata see for instance [WayBackRe: {userappdata} problem on Vista/UAC:

What you should do is to copy *template* files (or no files at all, if their contents can be embedded into or reconstructed by the app itself) into {app} (or under {commonappdata}). When your app starts up, first try to load the files from {userappdata}; if they're not there, load them from {app}/{commonappdata} instead. Always save files to {userappdata}, regardless of where they were loaded from; treat the ones in {app}/{commonappdata} as read-only.

Your installer should avoid touching user paths ({user*}, HKCU) at all; that's your app's job.

Other links that helped me:

Have you looked in the inno-setup documentation? I believe you can find the AppData folder as a macro. {localappdata} are the three AppData folders. – Warren P Mar 14 ’13 at 12:55


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: