winspool: Return ERROR_MORE_DATA, when the app probe for the needed buffer size.

This commit is contained in:
Detlef Riekenberg 2010-06-16 00:42:23 +02:00 committed by Alexandre Julliard
parent 8e151f5126
commit 18193b193b
2 changed files with 27 additions and 0 deletions

View File

@ -5367,6 +5367,8 @@ DWORD WINAPI GetPrinterDataExA(HANDLE hPrinter, LPCSTR pKeyName,
ret = RegOpenKeyW(HKEY_LOCAL_MACHINE, PrintersW, &hkeyPrinters);
if (ret) return ret;
TRACE("printer->name: %s\n", debugstr_w(printer->name));
if (printer->name) {
ret = RegOpenKeyW(hkeyPrinters, printer->name, &hkeyPrinter);
@ -5385,9 +5387,13 @@ DWORD WINAPI GetPrinterDataExA(HANDLE hPrinter, LPCSTR pKeyName,
ret = RegQueryValueExA(printer->name ? hkeySubkey : hkeyPrinters, pValueName,
0, pType, pData, pcbNeeded);
if (!ret && !pData) ret = ERROR_MORE_DATA;
RegCloseKey(hkeySubkey);
RegCloseKey(hkeyPrinter);
RegCloseKey(hkeyPrinters);
TRACE("--> %d\n", ret);
return ret;
}
@ -5411,6 +5417,8 @@ DWORD WINAPI GetPrinterDataExW(HANDLE hPrinter, LPCWSTR pKeyName,
ret = RegOpenKeyW(HKEY_LOCAL_MACHINE, PrintersW, &hkeyPrinters);
if (ret) return ret;
TRACE("printer->name: %s\n", debugstr_w(printer->name));
if (printer->name) {
ret = RegOpenKeyW(hkeyPrinters, printer->name, &hkeyPrinter);
@ -5429,9 +5437,13 @@ DWORD WINAPI GetPrinterDataExW(HANDLE hPrinter, LPCWSTR pKeyName,
ret = RegQueryValueExW(printer->name ? hkeySubkey : hkeyPrinters, pValueName,
0, pType, pData, pcbNeeded);
if (!ret && !pData) ret = ERROR_MORE_DATA;
RegCloseKey(hkeySubkey);
RegCloseKey(hkeyPrinter);
RegCloseKey(hkeyPrinters);
TRACE("--> %d\n", ret);
return ret;
}

View File

@ -2364,6 +2364,14 @@ static void test_GetPrinterData(void)
ok( !res && (type == REG_SZ) && ((needed == len) || (needed == (len * sizeof(WCHAR)))),
"got %d, type %d, needed: %d and '%s' (expected ERROR_SUCCESS, REG_SZ and %d or %d)\n",
res, type, needed, buffer, len, len * sizeof(WCHAR));
needed = 0xdeadbeef;
SetLastError(0xdeadbeef);
res = GetPrinterDataA(hprn, defaultspooldirectory, NULL, NULL, 0, &needed);
ok( (res == ERROR_MORE_DATA) && ((needed == len) || (needed == (len * sizeof(WCHAR)))),
"got %d, needed: %d (expected ERROR_MORE_DATA and %d or %d)\n",
res, needed, len, len * sizeof(WCHAR));
/* ToDo: test SPLREG_* */
SetLastError(0xdeadbeef);
@ -2451,6 +2459,13 @@ static void test_GetPrinterDataEx(void)
"got %d, type %d, needed: %d and '%s' (expected ERROR_SUCCESS, REG_SZ and %d or %d)\n",
res, type, needed, buffer, len, len * sizeof(WCHAR));
needed = 0xdeadbeef;
SetLastError(0xdeadbeef);
res = pGetPrinterDataExA(hprn, NULL, defaultspooldirectory, NULL, NULL, 0, &needed);
ok( (res == ERROR_MORE_DATA) && ((needed == len) || (needed == (len * sizeof(WCHAR)))),
"got %d, needed: %d (expected ERROR_MORE_DATA and %d or %d)\n",
res, needed, len, len * sizeof(WCHAR));
SetLastError(0xdeadbeef);
res = ClosePrinter(hprn);
ok(res, "ClosePrinter error %d\n", GetLastError());