I am creating a DLL that goes with a 3rd-party program. Whether or not the 3rd-party program has Administrator rights in Windows is outside my control.
The DLL needs to create a directory, but it seems like CreateDirectory won't work because it doesn't have administrator rights.
Escalating the UAC isn't an option because I am only modifying the DLL, not the 3rd-party program. I can't force the user to right-click the 3rd-party program and "Run As Administrator".
(Visual C++ 2010)
EDIT
I am trying to write to C:\\ProgramData\\
. I retrieve that path using SHGetFolderPath()
and CSIDL_COMMON_APPDATA
.
Use CSIDL_APPDATA
as the root folder for any user-specific directories/files, otherwise use CSIDL_COMMON_APPDATA
instead. Either way, create your own subfolder under the chosen root for your app/DLL, as the root folder itself is protected from being written to. Typically, an installer should create your subfolder with adequate rights, and then the app/DLL can access it as needed.
Read the TEMP
environment variable, and use the result to create temporary files and/or directories. Use APPDATA
for persistent ones.
Please note that at least APPDATA
is user specific.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.