winspool: Update the default settings when deleting the default printer.

This commit is contained in:
Huw Davies 2012-04-20 11:19:28 +01:00 committed by Alexandre Julliard
parent c0140118be
commit 1aa5696c93
1 changed files with 14 additions and 0 deletions

View File

@ -2812,6 +2812,8 @@ BOOL WINAPI DeletePrinter(HANDLE hPrinter)
{
LPCWSTR lpNameW = get_opened_printer_name(hPrinter);
HKEY hkeyPrinters, hkey;
WCHAR def[MAX_PATH];
DWORD size = sizeof( def ) / sizeof( def[0] );
if(!lpNameW) {
SetLastError(ERROR_INVALID_HANDLE);
@ -2833,6 +2835,18 @@ BOOL WINAPI DeletePrinter(HANDLE hPrinter)
RegDeleteValueW(hkey, lpNameW);
RegCloseKey(hkey);
}
if (GetDefaultPrinterW( def, &size ) && !strcmpW( def, lpNameW ))
{
WriteProfileStringW( windowsW, deviceW, NULL );
if (!RegCreateKeyW( HKEY_CURRENT_USER, user_default_reg_key, &hkey ))
{
RegDeleteValueW( hkey, deviceW );
RegCloseKey( hkey );
}
SetDefaultPrinterW( NULL );
}
return TRUE;
}