diff --git a/dlls/winspool/info.c b/dlls/winspool/info.c index a075c95e463..9f3e7d84add 100644 --- a/dlls/winspool/info.c +++ b/dlls/winspool/info.c @@ -2686,6 +2686,71 @@ BOOL WINAPI EnumPortsA(LPSTR name,DWORD level,LPBYTE ports,DWORD bufsize, return FALSE; } +/****************************************************************************** + * GetDefaultPrinterA (WINSPOOL.@) + * + * Based on PRINTDLG_GetDefaultPrinterName in dlls/commdlg/printdlg.c + */ +BOOL WINAPI GetDefaultPrinterA(LPSTR name, LPDWORD namesize) +{ + char *ptr; + + if (*namesize < 1) + { + SetLastError (ERROR_INSUFFICIENT_BUFFER); + return FALSE; + } + + if (!GetProfileStringA ("windows", "device", "", name, *namesize)) + { + SetLastError (ERROR_FILE_NOT_FOUND); + return FALSE; + } + + if ((ptr = strchr (name, ',')) == NULL) + { + SetLastError (ERROR_FILE_NOT_FOUND); + return FALSE; + } + + *ptr = '\0'; + *namesize = strlen (name) + 1; + return TRUE; +} + + +/****************************************************************************** + * GetDefaultPrinterW (WINSPOOL.@) + */ +BOOL WINAPI GetDefaultPrinterW(LPWSTR name, LPDWORD namesize) +{ + char *buf; + BOOL ret; + + if (*namesize < 1) + { + SetLastError (ERROR_INSUFFICIENT_BUFFER); + return FALSE; + } + + buf = HeapAlloc (GetProcessHeap (), 0, *namesize); + ret = GetDefaultPrinterA (buf, namesize); + if (ret) + { + DWORD len = MultiByteToWideChar (CP_ACP, 0, buf, -1, name, *namesize); + if (!len) + { + SetLastError (ERROR_INSUFFICIENT_BUFFER); + ret = FALSE; + } + else *namesize = len; + } + + HeapFree (GetProcessHeap (), 0, buf); + return ret; +} + + /****************************************************************************** * SetPrinterDataExA (WINSPOOL.@) */ diff --git a/dlls/winspool/winspool.drv.spec b/dlls/winspool/winspool.drv.spec index 2153f7213b6..50322a2ff73 100644 --- a/dlls/winspool/winspool.drv.spec +++ b/dlls/winspool/winspool.drv.spec @@ -94,6 +94,8 @@ debug_channels (winspool) @ stub FindFirstPrinterChangeNotification @ stub FindNextPrinterChangeNotification @ stub FreePrinterNotifyInfo +@ stdcall GetDefaultPrinterA(str ptr) GetDefaultPrinterA +@ stdcall GetDefaultPrinterW(wstr ptr) GetDefaultPrinterW @ stdcall GetFormA(long str long ptr long ptr) GetFormA @ stdcall GetFormW(long wstr long ptr long ptr) GetFormW @ stub GetJobA diff --git a/include/winspool.h b/include/winspool.h index 3e98df82272..ceb15610b4f 100644 --- a/include/winspool.h +++ b/include/winspool.h @@ -888,6 +888,10 @@ BOOL WINAPI EnumPrinterDriversW(LPWSTR pName, LPWSTR pEnvironment, DWORD Level, LPDWORD pcbNeeded, LPDWORD pcbReturned); #define EnumPrinterDrivers WINELIB_NAME_AW(EnumPrinterDrivers) +BOOL WINAPI GetDefaultPrinterA(LPSTR pName, LPDWORD pcbNameSize); +BOOL WINAPI GetDefaultPrinterW(LPWSTR pName, LPDWORD pcbNameSize); +#define GetDefaultPrinter WINELIB_NAME_AW(GetDefaultPrinter) + BOOL WINAPI DeletePrinterDriverA(LPSTR pName, LPSTR pEnvironment, LPSTR pDriverName); BOOL WINAPI DeletePrinterDriverW(LPWSTR pName, LPWSTR pEnvironment,