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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With