Commit e18682ad authored by Robert Shearman's avatar Robert Shearman Committed by Alexandre Julliard

Remove PRINTDLG_GetDefaultPrinterName; use Win32 GetDefaultPrinterA/W

instead.
parent fbaab7d8
...@@ -72,52 +72,6 @@ static struct pd_flags psd_flags[] = { ...@@ -72,52 +72,6 @@ static struct pd_flags psd_flags[] = {
}; };
/*********************************************************************** /***********************************************************************
* PRINTDLG_GetDefaultPrinterName
*
* Returns the default printer name in buf.
* Even under WinNT/2000 default printer is retrieved via GetProfileString -
* these entries are mapped somewhere in the registry rather than win.ini.
*
* Returns TRUE on success else FALSE
*/
BOOL PRINTDLG_GetDefaultPrinterNameA(LPSTR buf, DWORD len)
{
char *ptr;
if(!GetProfileStringA("windows", "device", "", buf, len)) {
TRACE("No profile entry for default printer found.\n");
return FALSE;
}
if((ptr = strchr(buf, ',')) == NULL) {
FIXME("bad format for default printer (%s)!\n",buf);
return FALSE;
}
*ptr = '\0';
return TRUE;
}
static BOOL PRINTDLG_GetDefaultPrinterNameW(LPWSTR buf, DWORD len)
{
LPSTR ptr, bufA = (LPSTR)HeapAlloc(GetProcessHeap(),0,len+1);
if(!GetProfileStringA("windows", "device", "", bufA, len)) {
TRACE("No profile entry for default printer found.\n");
HeapFree(GetProcessHeap(),0,bufA);
return FALSE;
}
if((ptr = strchr(bufA, ',')) == NULL) {
FIXME("bad format for default printer (%s)!\n",bufA);
HeapFree(GetProcessHeap(),0,bufA);
return FALSE;
}
*ptr = '\0';
MultiByteToWideChar( CP_ACP, 0, bufA, -1, buf, len );
HeapFree(GetProcessHeap(),0,bufA);
return TRUE;
}
/***********************************************************************
* PRINTDLG_OpenDefaultPrinter * PRINTDLG_OpenDefaultPrinter
* *
* Returns a winspool printer handle to the default printer in *hprn * Returns a winspool printer handle to the default printer in *hprn
...@@ -128,8 +82,9 @@ static BOOL PRINTDLG_GetDefaultPrinterNameW(LPWSTR buf, DWORD len) ...@@ -128,8 +82,9 @@ static BOOL PRINTDLG_GetDefaultPrinterNameW(LPWSTR buf, DWORD len)
BOOL PRINTDLG_OpenDefaultPrinter(HANDLE *hprn) BOOL PRINTDLG_OpenDefaultPrinter(HANDLE *hprn)
{ {
char buf[260]; char buf[260];
DWORD dwBufLen = sizeof(buf);
BOOL res; BOOL res;
if(!PRINTDLG_GetDefaultPrinterNameA(buf, sizeof(buf))) if(!GetDefaultPrinterA(buf, &dwBufLen))
return FALSE; return FALSE;
res = OpenPrinterA(buf, hprn, NULL); res = OpenPrinterA(buf, hprn, NULL);
if (!res) if (!res)
...@@ -170,9 +125,10 @@ INT PRINTDLG_SetUpPrinterListComboA(HWND hDlg, UINT id, LPCSTR name) ...@@ -170,9 +125,10 @@ INT PRINTDLG_SetUpPrinterListComboA(HWND hDlg, UINT id, LPCSTR name)
(LPARAM)name)) == CB_ERR) { (LPARAM)name)) == CB_ERR) {
char buf[260]; char buf[260];
DWORD dwBufLen = sizeof(buf);
FIXME("Can't find '%s' in printer list so trying to find default\n", FIXME("Can't find '%s' in printer list so trying to find default\n",
name); name);
if(!PRINTDLG_GetDefaultPrinterNameA(buf, sizeof(buf))) if(!GetDefaultPrinterA(buf, &dwBufLen))
return num; return num;
i = SendDlgItemMessageA(hDlg, id, CB_FINDSTRINGEXACT, -1, (LPARAM)buf); i = SendDlgItemMessageA(hDlg, id, CB_FINDSTRINGEXACT, -1, (LPARAM)buf);
if(i == CB_ERR) if(i == CB_ERR)
...@@ -203,9 +159,10 @@ static INT PRINTDLG_SetUpPrinterListComboW(HWND hDlg, UINT id, LPCWSTR name) ...@@ -203,9 +159,10 @@ static INT PRINTDLG_SetUpPrinterListComboW(HWND hDlg, UINT id, LPCWSTR name)
/* ansi is ok */ /* ansi is ok */
char buf[260]; char buf[260];
DWORD dwBufLen = sizeof(buf);
FIXME("Can't find '%s' in printer list so trying to find default\n", FIXME("Can't find '%s' in printer list so trying to find default\n",
debugstr_w(name)); debugstr_w(name));
if(!PRINTDLG_GetDefaultPrinterNameA(buf, sizeof(buf))) if(!GetDefaultPrinterA(buf, &dwBufLen))
return num; return num;
i = SendDlgItemMessageA(hDlg, id, CB_FINDSTRINGEXACT, -1, (LPARAM)buf); i = SendDlgItemMessageA(hDlg, id, CB_FINDSTRINGEXACT, -1, (LPARAM)buf);
if(i == CB_ERR) if(i == CB_ERR)
...@@ -231,6 +188,7 @@ static BOOL PRINTDLG_CreateDevNames(HGLOBAL *hmem, char* DeviceDriverName, ...@@ -231,6 +188,7 @@ static BOOL PRINTDLG_CreateDevNames(HGLOBAL *hmem, char* DeviceDriverName,
char* pTempPtr; char* pTempPtr;
LPDEVNAMES lpDevNames; LPDEVNAMES lpDevNames;
char buf[260]; char buf[260];
DWORD dwBufLen = sizeof(buf);
size = strlen(DeviceDriverName) + 1 size = strlen(DeviceDriverName) + 1
+ strlen(DeviceName) + 1 + strlen(DeviceName) + 1
...@@ -259,7 +217,7 @@ static BOOL PRINTDLG_CreateDevNames(HGLOBAL *hmem, char* DeviceDriverName, ...@@ -259,7 +217,7 @@ static BOOL PRINTDLG_CreateDevNames(HGLOBAL *hmem, char* DeviceDriverName,
strcpy(pTempPtr, OutputPort); strcpy(pTempPtr, OutputPort);
lpDevNames->wOutputOffset = pTempPtr - pDevNamesSpace; lpDevNames->wOutputOffset = pTempPtr - pDevNamesSpace;
PRINTDLG_GetDefaultPrinterNameA(buf, sizeof(buf)); GetDefaultPrinterA(buf, &dwBufLen);
lpDevNames->wDefault = (strcmp(buf, DeviceName) == 0) ? 1 : 0; lpDevNames->wDefault = (strcmp(buf, DeviceName) == 0) ? 1 : 0;
GlobalUnlock(*hmem); GlobalUnlock(*hmem);
return TRUE; return TRUE;
...@@ -273,7 +231,7 @@ static BOOL PRINTDLG_CreateDevNamesW(HGLOBAL *hmem, LPCWSTR DeviceDriverName, ...@@ -273,7 +231,7 @@ static BOOL PRINTDLG_CreateDevNamesW(HGLOBAL *hmem, LPCWSTR DeviceDriverName,
LPWSTR pTempPtr; LPWSTR pTempPtr;
LPDEVNAMES lpDevNames; LPDEVNAMES lpDevNames;
WCHAR bufW[260]; WCHAR bufW[260];
char buf[260]; DWORD dwBufLen = sizeof(bufW) / sizeof(WCHAR);
size = sizeof(WCHAR)*lstrlenW(DeviceDriverName) + 2 size = sizeof(WCHAR)*lstrlenW(DeviceDriverName) + 2
+ sizeof(WCHAR)*lstrlenW(DeviceName) + 2 + sizeof(WCHAR)*lstrlenW(DeviceName) + 2
...@@ -302,8 +260,7 @@ static BOOL PRINTDLG_CreateDevNamesW(HGLOBAL *hmem, LPCWSTR DeviceDriverName, ...@@ -302,8 +260,7 @@ static BOOL PRINTDLG_CreateDevNamesW(HGLOBAL *hmem, LPCWSTR DeviceDriverName,
lstrcpyW(pTempPtr, OutputPort); lstrcpyW(pTempPtr, OutputPort);
lpDevNames->wOutputOffset = pTempPtr - pDevNamesSpace; lpDevNames->wOutputOffset = pTempPtr - pDevNamesSpace;
PRINTDLG_GetDefaultPrinterNameA(buf, sizeof(buf)); GetDefaultPrinterW(bufW, &dwBufLen);
MultiByteToWideChar(CP_ACP, 0, buf, -1, bufW, -1);
lpDevNames->wDefault = (lstrcmpW(bufW, DeviceName) == 0) ? 1 : 0; lpDevNames->wDefault = (lstrcmpW(bufW, DeviceName) == 0) ? 1 : 0;
GlobalUnlock(*hmem); GlobalUnlock(*hmem);
return TRUE; return TRUE;
...@@ -1317,7 +1274,8 @@ static LRESULT PRINTDLG_WMInitDialog(HWND hDlg, WPARAM wParam, ...@@ -1317,7 +1274,8 @@ static LRESULT PRINTDLG_WMInitDialog(HWND hDlg, WPARAM wParam,
} else { } else {
/* else use default printer */ /* else use default printer */
char name[200]; char name[200];
BOOL ret = PRINTDLG_GetDefaultPrinterNameA(name, sizeof(name)); DWORD dwBufLen = sizeof(name);
BOOL ret = GetDefaultPrinterA(name, &dwBufLen);
if (ret) if (ret)
PRINTDLG_ChangePrinterA(hDlg, name, PrintStructures); PRINTDLG_ChangePrinterA(hDlg, name, PrintStructures);
...@@ -1421,7 +1379,8 @@ static LRESULT PRINTDLG_WMInitDialogW(HWND hDlg, WPARAM wParam, ...@@ -1421,7 +1379,8 @@ static LRESULT PRINTDLG_WMInitDialogW(HWND hDlg, WPARAM wParam,
} else { } else {
/* else use default printer */ /* else use default printer */
WCHAR name[200]; WCHAR name[200];
BOOL ret = PRINTDLG_GetDefaultPrinterNameW(name, sizeof(name)); DWORD dwBufLen = sizeof(name) / sizeof(WCHAR);
BOOL ret = GetDefaultPrinterW(name, &dwBufLen);
if (ret) if (ret)
PRINTDLG_ChangePrinterW(hDlg, name, PrintStructures); PRINTDLG_ChangePrinterW(hDlg, name, PrintStructures);
......
...@@ -99,7 +99,6 @@ static struct pd_flags { ...@@ -99,7 +99,6 @@ static struct pd_flags {
* Do not Export to other applications or dlls * Do not Export to other applications or dlls
*/ */
BOOL PRINTDLG_GetDefaultPrinterNameA(LPSTR buf, DWORD len);
INT PRINTDLG_SetUpPrinterListComboA(HWND hDlg, UINT id, LPCSTR name); INT PRINTDLG_SetUpPrinterListComboA(HWND hDlg, UINT id, LPCSTR name);
BOOL PRINTDLG_ChangePrinterA(HWND hDlg, char *name, BOOL PRINTDLG_ChangePrinterA(HWND hDlg, char *name,
PRINT_PTRA *PrintStructures); PRINT_PTRA *PrintStructures);
......
...@@ -56,6 +56,7 @@ static BOOL PRINTDLG_CreateDevNames16(HGLOBAL16 *hmem, char* DeviceDriverName, ...@@ -56,6 +56,7 @@ static BOOL PRINTDLG_CreateDevNames16(HGLOBAL16 *hmem, char* DeviceDriverName,
char* pTempPtr; char* pTempPtr;
LPDEVNAMES lpDevNames; LPDEVNAMES lpDevNames;
char buf[260]; char buf[260];
DWORD dwBufLen = sizeof(buf);
size = strlen(DeviceDriverName) + 1 size = strlen(DeviceDriverName) + 1
+ strlen(DeviceName) + 1 + strlen(DeviceName) + 1
...@@ -84,7 +85,7 @@ static BOOL PRINTDLG_CreateDevNames16(HGLOBAL16 *hmem, char* DeviceDriverName, ...@@ -84,7 +85,7 @@ static BOOL PRINTDLG_CreateDevNames16(HGLOBAL16 *hmem, char* DeviceDriverName,
strcpy(pTempPtr, OutputPort); strcpy(pTempPtr, OutputPort);
lpDevNames->wOutputOffset = pTempPtr - pDevNamesSpace; lpDevNames->wOutputOffset = pTempPtr - pDevNamesSpace;
PRINTDLG_GetDefaultPrinterNameA(buf, sizeof(buf)); GetDefaultPrinterA(buf, &dwBufLen);
lpDevNames->wDefault = (strcmp(buf, DeviceName) == 0) ? 1 : 0; lpDevNames->wDefault = (strcmp(buf, DeviceName) == 0) ? 1 : 0;
GlobalUnlock16(*hmem); GlobalUnlock16(*hmem);
return TRUE; return TRUE;
...@@ -195,7 +196,8 @@ static LRESULT PRINTDLG_WMInitDialog16(HWND hDlg, WPARAM wParam, ...@@ -195,7 +196,8 @@ static LRESULT PRINTDLG_WMInitDialog16(HWND hDlg, WPARAM wParam,
} else { } else {
/* else just use default printer */ /* else just use default printer */
char name[200]; char name[200];
BOOL ret = PRINTDLG_GetDefaultPrinterNameA(name, sizeof(name)); DWORD dwBufLen = sizeof(name);
BOOL ret = GetDefaultPrinterA(name, &dwBufLen);
if (ret) if (ret)
PRINTDLG_ChangePrinterA(hDlg, name, PrintStructures); PRINTDLG_ChangePrinterA(hDlg, name, PrintStructures);
......
...@@ -3116,8 +3116,6 @@ BOOL WINAPI EnumPortsA(LPSTR name,DWORD level,LPBYTE buffer,DWORD bufsize, ...@@ -3116,8 +3116,6 @@ BOOL WINAPI EnumPortsA(LPSTR name,DWORD level,LPBYTE buffer,DWORD bufsize,
/****************************************************************************** /******************************************************************************
* GetDefaultPrinterA (WINSPOOL.@) * GetDefaultPrinterA (WINSPOOL.@)
*
* Based on PRINTDLG_GetDefaultPrinterName in dlls/commdlg/printdlg.c
*/ */
BOOL WINAPI GetDefaultPrinterA(LPSTR name, LPDWORD namesize) BOOL WINAPI GetDefaultPrinterA(LPSTR name, LPDWORD namesize)
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment