NvAPI_DRS_EnumApplications doesn't work well.

Hello. I think there are some structure size error on NvAPI_DRS_EnumApplications.

I made a code which is exactly the same of your “NVIDIA Driver Settings Programming Guide” p.9.

for (i = 0; i < numAppsRead; ++i) {
wprintf(L"Excutable: %s\n",appArray[i].appName);
wprintf(L"User Friendly Name: %s\n", appArray[i].userFriendlyName);
printf(“Is Predefined: %d\n”, appArray[i].isPredefined);
}

appArray[0] is printed well but there are problems from appArray[1].
It missing some letter like “Excutable: showcase.exe” -> “Excutable: owcaes.exe”.
I think maybe the size of structure is wrong.

System:
Quadro K5000, Win8
NVDRS_APPLICATION_VER_V2.
(“NVDRS_APPLICATION_VER”(NVDRS_APPLICATION_VER_V3) doesn’t works even though my driver version is the latest; 311.06. How can I know which application version should I use?)

Similar problems are occur at NvAPI_DRS_EnumSettings.

There is no such bug of NvAPI_DRS_EnumApplications in NVAPI Apr-2012 release.
But there are still problems in NvAPI_DRS_EnumSettings.

Application works well.

if (profileInformation.numOfApps > 0) {
NVDRS_APPLICATION* appArray = new NVDRS_APPLICATION[profileInformation.numOfApps];
NvU32 numAppRead = profileInformation.numOfApps, i;

appArray[0].version = NVDRS_APPLICATION_VER;

m_status = NvAPI_DRS_EnumApplications(m_hSession, hProfile, 0, &numAppRead, appArray);
if (m_status.IsError()) {
	delete[] appArray;
	return false;
}

for (i = 0; i < numAppRead; ++i) {
	m_status = NvAPI_DRS_CreateApplication(hTempSession, hTempProfile, &appArray[i]); 
	STATUS_ERROR_RETURN_FALSE;
}
delete[] appArray;

}

Every “appArray[i].version” is “NVDRS_APPLICATION_VER”.
That means I can use it directly to “NvAPI_DRS_CreateApplication” function.

But settings…

if (profileInformation.numOfSettings > 0) {
NVDRS_SETTING* setArray = new NVDRS_SETTING[profileInformation.numOfSettings];
NvU32 numSetRead = profileInformation.numOfSettings, i;

setArray[0].version = NVDRS_SETTING_VER;

m_status = NvAPI_DRS_EnumSettings(m_hSession, hProfile, 0, &numSetRead, setArray);
if (m_status.IsError()) {
	delete[] setArray;
	return false;
}

for (i = 0; i < numSetRead; ++i) {
	m_status = NvAPI_DRS_SetSetting(hTempSession, hTempProfile, &setArray[i]);
	STATUS_ERROR_RETURN_FALSE;		
}
delete[] setArray;

}

Only “setArray[0].version” is “NVDRS_SETTING_VER”.
I can’t use it directly to “NvAPI_DRS_SetSetting” function.
It returns “NVAPI_INCOMPATIBLE_STRUCT_VERSION”.

NvAPI_DRS_EnumApplications can’t get input of NVDRS_APPLICATION_VER_V3(NVDRS_APPLICATION_VER), but returns output of NVDRS_APPLICATION_VER_V3 structure (NVDRS_APPLICATION). So, I converted NVDRS_APPICATION* to NVDRS_APPLICATION_V2 and it works right.

if (profileInformation.numOfApps > 0) {
NVDRS_APPLICATION* appArray = new NVDRS_APPLICATION[profileInformation.numOfApps];
NvU32 numAppsRead = profileInformation.numOfApps, i;

appArray[0].version = NVDRS_APPLICATION_VER_V2; // NVDRS_APPLICATION_VER impossible
m_status = NvAPI_DRS_EnumApplications(m_hSession, hProfile, 0, &numAppsRead, appArray);
if (m_status.IsError()) {
	delete[] appArray;
	return false;
}
NVDRS_APPLICATION_V2* appArrayV2 = (NVDRS_APPLICATION_V2*)appArray;
for (i = 0; i < numAppsRead; ++i) {
	std::wcout << L"Excutable: " << (wchar_t*)appArrayV2[i].appName << std::endl;
	std::wcout << L"User Friendly Name: " << (wchar_t*)appArrayV2[i].userFriendlyName << std::endl;
	std::wcout << L"Luncher: " << (wchar_t*)appArrayV2[i].launcher << std::endl;
	std::wcout << L"Is Predefined: " << appArrayV2[i].isPredefined << std::endl;
}
delete[] appArray;

}