📄 uidevcaps.cpp
字号:
/* * * UIDevCaps.cpp * Copyright (C) 2006 Michael H. Overlin This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Contact at poster_printer@yahoo.com */#include "UIDevCaps.h"#include "UIDevMode.h"#include "..\lib\printResizerCommon.h"#include "..\lib\extDevMode.h"#include "..\lib\fallback.h"#include "..\lib\spoolutils.h"#include "..\lib\utils.h"#include <windows.h>#include <malloc.h>#include <strsafe.h>#include <winspool.h>// NEED TO TAKE INTO ACCOUNT DIFFERENCE BETWEEN// OUR CAPS, TARGET CAPSDWORD DrvDeviceCapabilities( HANDLE hPrinter, PWSTR pDeviceName, WORD iDevCap, VOID *pvOutput, PDEVMODE pDevMode ) { DWORD dwRetValue = GDI_ERROR; LPCTSTR lptstrTargetPrinterName = NULL; static BOOL bBreak = STATICBOOLBREAK; ASSERT(!bBreak); PEXTDEVMODE pextdm = ::EXTDM_New(); if (pextdm != NULL) { // DEBUG / FIX: NOT SURE pDeviceName IS ALWAYS VALID ... ASSERT(pDeviceName != NULL); ::EXTDM_SetAppDevMode(pextdm, pDevMode, pDeviceName); PCDEVMODE pdmTarget = ::EXTDM_GetTargetPrinterDevMode(pextdm); // DEBUG / FIX: WE SHOULD CHECK FOR CASE THAT TARGET IS OURSELF, WITH A TARGET OF OURSELF AGAIN // IN THAT CASE WE HAVE TO RETURN DEVICE CAPABILITY OURSELF if (pdmTarget != NULL) { ::PPRINTER_INFO_2 pinfo = ::GetPrinterInfo2(::EXTDM_GetTargetPrinterName(pextdm)); if (pinfo != NULL) { // 6/23 //dwRetValue = ::DeviceCapabilities(pinfo->pPrinterName, pinfo->pPortName, // iDevCap, (LPTSTR) pvOutput, pdmTarget); BOOL bError = FALSE; BOOL bFallBack = FALSE; if ( ::EXTDM_IsAnExtDevMode(pdmTarget) ) { PCEXTDEVMODE pextdmTarget = (PCEXTDEVMODE) pdmTarget; BOOL bCircular; if ( ::EXTDM_IsCircular(bCircular, pextdmTarget) ) { bFallBack = bCircular; } else { // WE COULDN'T CHECK IF THE TARGET IS OURS WITH A CIRCULAR REF bError = TRUE; } } if (!bError) { if (!bFallBack) { dwRetValue = ::DeviceCapabilities(pinfo->pPrinterName, pinfo->pPortName, iDevCap, (LPTSTR) pvOutput, pdmTarget); } else { dwRetValue = ::Fallback_GetDeviceCapabilities(hPrinter, iDevCap, pvOutput); } } free(pinfo); } ::EXTDM_ReleaseTargetPrinterDevMode(pextdm, pdmTarget); } ::EXTDM_Delete(pextdm); } return dwRetValue;}// dwRetValue = Fallback_GetDeviceCapabilities(// hPrinter, iDevCap, pvOutput);// }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -