Unhandle exception when executing NvAPI_DISP_GetDisplayConfig( ... )

Hello, I’m currently trying to use the function NvAPI_DISP_GetDisplayConfig( … ), and NVAPI64.dll throws an exception during the 2nd call to the function:

Unhandled exception at 0x000007F967FA7275 (nvapi64.dll) in NVAPI_WACOM.exe: 0xC0000005: Access violation reading location 0xFFFFFFFFFFFFFFFF.

Here’s the code I’m using, and I’ve double-checked the NVAPI Documentation to make sure I’m following everything correctly. I have the Quadro Driver 320.00 installed and currently have 3 video cards: Quadro FX1700, FX580 and K2000D. Also, I’m using Windows 8 x64. Thanks!

NvAPI_Status status;
	// (0) Initialize NVAPI. This must be done first of all
	status = NvAPI_Initialize();

	NvU32 PathInfoCount=0;
	NV_DISPLAYCONFIG_PATH_INFO * myPathInfo=NULL;

	//Get PathInfoCount so that I can allocate an appropriate buffer
	NvAPI_DISP_GetDisplayConfig(&PathInfoCount, myPathInfo);

	//Allocate the buffer
	myPathInfo = (NV_DISPLAYCONFIG_PATH_INFO *)malloc(sizeof(NV_DISPLAYCONFIG_PATH_INFO) * PathInfoCount);

	//Add correct Version info to freshly allocated buffer
	for (NvU32 piInit=0; piInit<PathInfoCount; piInit++)
	{
		myPathInfo[piInit].version = NV_DISPLAYCONFIG_PATH_INFO_VER;
		myPathInfo[piInit].sourceModeInfo = (NV_DISPLAYCONFIG_SOURCE_MODE_INFO *)malloc(sizeof(NV_DISPLAYCONFIG_SOURCE_MODE_INFO));
		myPathInfo[piInit].reserved=0;
	}

	//Now get the PathInfo Array
	NvAPI_DISP_GetDisplayConfig(&PathInfoCount, myPathInfo);  //<---This throws the exception

Can anybody see anything that I’m doing wrong? Is this a bug?

Also, I tried running the included sample (customtiming.cpp) [it failed], tried another NvAPI_DISP_XXX function and it failed.

Is there something I missing regarding the use of the NvAPI_DISP_XXX functions?

Well, the solution is here:

You have to initialize more than what the API states [or even the samples show for that matter].

Hope it helps someone.