Skip to content

Instantly share code, notes, and snippets.

@bazhenovc
Created September 7, 2016 15:03
Show Gist options
  • Save bazhenovc/01d1b9bf304ced8ab2ece0ea4dbf4b8d to your computer and use it in GitHub Desktop.
Save bazhenovc/01d1b9bf304ced8ab2ece0ea4dbf4b8d to your computer and use it in GitHub Desktop.
nvapi force discrete card
void nvidiaForceUseDiscreteCard()
{
NvAPI_Status status = NvAPI_Initialize();
if(status != NVAPI_OK) return;
NvDRSSessionHandle hSession = 0;
status = NvAPI_DRS_CreateSession(&hSession);
if(status != NVAPI_OK) return;
status = NvAPI_DRS_LoadSettings(hSession);
if(status != NVAPI_OK) return;
NvDRSProfileHandle hProfile = 0;
status = NvAPI_DRS_GetBaseProfile(hSession, &hProfile);
if(status != NVAPI_OK) return;
NVDRS_SETTING drsSetting1 = {0};
drsSetting1.version = NVDRS_SETTING_VER;
drsSetting1.settingId = SHIM_MCCOMPAT_ID;
drsSetting1.settingType = NVDRS_DWORD_TYPE;
NVDRS_SETTING drsSetting2 = {0};
drsSetting2.version = NVDRS_SETTING_VER;
drsSetting2.settingId = SHIM_RENDERING_MODE_ID;
drsSetting2.settingType = NVDRS_DWORD_TYPE;
NVDRS_SETTING drsSetting3 = {0};
drsSetting3.version = NVDRS_SETTING_VER;
drsSetting3.settingId = SHIM_RENDERING_OPTIONS_ID;
drsSetting3.settingType = NVDRS_DWORD_TYPE;
drsSetting1.u32CurrentValue = SHIM_MCCOMPAT_ENABLE;
drsSetting2.u32CurrentValue = SHIM_RENDERING_MODE_ENABLE;
drsSetting3.u32CurrentValue = SHIM_RENDERING_OPTIONS_DEFAULT_RENDERING_MODE;
status = NvAPI_DRS_SetSetting(hSession, hProfile, &drsSetting1);
if(status != NVAPI_OK) return;
status = NvAPI_DRS_SetSetting(hSession, hProfile, &drsSetting2);
if(status != NVAPI_OK) return;
status = NvAPI_DRS_SetSetting(hSession, hProfile, &drsSetting3);
if(status != NVAPI_OK) return;
status = NvAPI_DRS_SaveSettings(hSession);
if(status != NVAPI_OK) return;
NvAPI_DRS_DestroySession(hSession);
hSession = 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment