Reputation: 3527
I'm working on an ActiveX that might find itself running in Windows7 when UAC is enabled.
In order to provide the ability to support customers once they have problems working with the ActiveX, today, I'm writing to a log file opened and managed by my code. The problem is that when UAC is enabled, I don't have permission to create/modify files.
Thanks a lot.
Upvotes: 2
Views: 1883
Reputation: 14324
You can use SHGetKnownFolderPath to get the path for FOLDERID_LocalAppDataLow (which will usually be C:\Users\Your User\AppData\LocalLow) which you can then write to.
The challenge with this API is that it isn't available in Windows XP; so, if you're on XP, you have to use a different API which will just give you the Local Settings\Application Data folder; but, you can only use one or the other API, depending on how your windows version defines are set. The workaround is to manually load the shell32.dll library and search for the entrypoint, then fall back to the xp version if it doesn't work. That is what I did for FireBreath (which I use for my activex browser plugins). Sample code here.
For more information see Finding Low Integrity Write Locations
Hope it helps
Upvotes: 3