SHGetFolderPath returns path to admin user account when used in an installer

后端 未结 1 776
别那么骄傲
别那么骄傲 2021-01-17 07:07

I\'m using SHGetFolderPath CSIDL_APPDATA to get path to the application data folder under current user account. It works fine, but if it is called from an installer, Windows

相关标签:
1条回答
  • 2021-01-17 07:18

    SHGetFolderPath() has an hToken parameter for this exact situation. If hToken is NULL, the function uses the access token associated with the calling thread. Otherwise it can be set to an access token for another user account.

    If the installer is running elevated as an admin, the installer will have to either:

    1. impersonate the desired user account before calling SHGetFolderPath().

    2. obtain an access token for the desired user account and pass it to hToken.

    0 讨论(0)
提交回复
热议问题