I’ve made a C++ DLL with custom WIX action, that creates/updates the profile for the app when installing, and removes it when uninstalled.
While almost undocumented, the official nVidia API has the required NvAPI_DRS_* functions for that.
Here’s a workflow: NvAPI_Initialize
(if failed it means the user doesn’t have nVidia GPU, that’s not an error), NvAPI_DRS_CreateSession
, NvAPI_DRS_LoadSettings
, NvAPI_DRS_FindProfileByName
.
If was not found, NvAPI_DRS_CreateProfile
, and three calls to NvAPI_DRS_SetSetting
, setting three DWORD properties:
- SHIM_MCCOMPAT_ID = SHIM_MCCOMPAT_ENABLE
- SHIM_RENDERING_MODE_ID = SHIM_RENDERING_MODE_ENABLE
- SHIM_RENDERING_OPTIONS_ID = SHIM_RENDERING_OPTIONS_DEFAULT_RENDERING_MODE
Then, call NvAPI_DRS_GetProfileInfo
to get number of applications, followed by NvAPI_DRS_EnumApplications
, and search for the EXE path.
When uninstalling, I delete the complete profile, by calling NvAPI_DRS_FindProfileByName
and then NvAPI_DRS_DeleteProfile
.
On reinstall and upgrade I do both, first remove then add.
Don't forget NvAPI_DRS_SaveSettings
at the end.
P.S. Most unexpected thing is, nVidia “normalizes” paths stored in NVDRS_APPLICATION::appName field, they convert them to lowercase, and also replace '\'
with '/'
. Because of this “normalization”, no standard string comparison function will work for them.