+ // Determine the size of the DevMode.
+ dwErrorCode = (DWORD)RegQueryValueExW(hSubKey, L"Default DevMode", NULL, NULL, NULL, &cbData);
+ if (dwErrorCode != ERROR_SUCCESS)
+ {
+ ERR("Couldn't query the size of the DevMode for Printer \"%S\", status is %lu, cbData is %lu!\n", wszPrinterName, dwErrorCode, cbData);
+ continue;
+ }
+
+ // Allocate enough memory for the DevMode.
+ pPrinter->pDefaultDevMode = DllAllocSplMem(cbData);
+ if (!pPrinter->pDefaultDevMode)
+ {
+ dwErrorCode = ERROR_NOT_ENOUGH_MEMORY;
+ ERR("DllAllocSplMem failed with error %lu!\n", GetLastError());
+ goto Cleanup;
+ }
+