I need to write a shortcut in the automatic startup folder for all users.
The scenario is that a user with administrator privileges, through the configuration dialog of the application, must be able to set the application to start automatically for all normal users when they log in.
I get the startup folder using
SHGetSpecialFolderPath(NULL, startFolderPath开发者_开发知识库, CSIDL_COMMON_STARTUP, FALSE)
but then I don't have write privileges on that folder, even when the logged user is part of the Adminisrator's group.
I suppose I need to call some API function related to User Account Control (UAC) to ask permission to the logged user to elevate the current privilege.
This should work on Windows XP too
When you say you don't have write privileges on the folder, was the app or tool you were using to write running elevated? That is, running as admin? This is not the same as being run by an account that is an administrator. If not, right click the exe and choose Run As Administrator. This will elevate the app and probably enable it to complete the configuration task.
This is not related to User Access Control or Code Access Security. It's UAC that protects HKLM, Program Files, and other all-users, per-machine settings.
精彩评论