Virtualization is transparent to the app. The only way to know whether it is being virtualized is to ask the OS, per the answer in the question you linked to (use GetTokenInformation()
with the TokenVirtualizationEnabled
flag), but there is no way (that I know of) of asking the OS where the virtualized items are actually stored, as it may be different from one OS version to the next. You will have to do some research and then hard-code the paths for each given OS that your app detects at runtime.
If you are going to update your code to detect virtualization, then you are better off updating the code to play nicer with UAC instead. Stop storing your files where they do not belong, and start storing them where Microsoft wants you to store them. In this case, within the user's profile instead. Use SHGetFolderPath()
or related function to locate the user's CSIDL_LOCAL_APPDATA
folder (or SHGetKnownFolderPath()
on Vista+ to locate the FOLDERID_LocalAppData
folder), then create a subfolder underneath it for your app to store its data files in.