NvAPI_DISP_GetMonitorCapabilities返回NVAPI_INCOMPATIBLE_STRUCT_VERSION

时间:2019-04-14 15:44:24

标签: c++ nvidia nvapi

我对NvAPI_DISP_GetMonitorCapabilities函数有问题。 当我调用此函数时,它将返回我NVAPI_INCOMPATIBLE_STRUCT_VERSION。

NvAPI_Status nvapiReturnStatus = NVAPI_ERROR;

NV_GPU_DISPLAYIDS* pDisplayID = NULL;
NvU32 displayIdCount = 0;

NvPhysicalGpuHandle gpuHandleArray[NVAPI_MAX_PHYSICAL_GPUS] = { 0 };
NvU32 gpuCount = 0;

nvapiReturnStatus = GetGPUs(gpuHandleArray, gpuCount);
if (nvapiReturnStatus != NVAPI_OK)
{
    LogError("\n GetConnectedGPUs failed with error code : %s ", nvapiReturnStatus);
    return;
}

// Get all active outputs info for all gpu's
for (NvU32 i = 0; i < gpuCount; ++i)
{
    nvapiReturnStatus = GetConnectedDisplays(gpuHandleArray[i], &pDisplayID, displayIdCount);
    if (nvapiReturnStatus != NVAPI_OK)
    {
       LogError("\n GetConnectedDisplays failed with error code : %s ", nvapiReturnStatus);
       goto cleanup;
    }

    NV_MONITOR_CAPABILITIES_V1 monitorCaps;
    monitorCaps.version = NV_MONITOR_CAPABILITIES_VER1;
    memset(&monitorCaps, 0, sizeof(NV_MONITOR_CAPABILITIES_V1));

    for (NvU32 j = 0; j < displayIdCount; j++) 
    {
        nvapiReturnStatus = NvAPI_DISP_GetMonitorCapabilities(pDisplayID[j].displayId, &monitorCaps);
        //Here I get the error
    }
}

1 个答案:

答案 0 :(得分:0)

您似乎需要更改此内容:

monitorCaps.version = NV_MONITOR_CAPABILITIES_VER1;
memset(&monitorCaps, 0, sizeof(NV_MONITOR_CAPABILITIES_V1));

对此:

memset(&monitorCaps, 0, sizeof(NV_MONITOR_CAPABILITIES_V1));
monitorCaps.version = NV_MONITOR_CAPABILITIES_VER1;

或者您可以这样做:

NV_MONITOR_CAPABILITIES_V1 monitorCaps = { NV_MONITOR_CAPABILITIES_VER1 };