📄 uidevmode.cpp
字号:
/* * * UIDevMode.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 */#define UIDEVMODE_C#include "UIDevMode.h"#include "..\lib\devmode.h"#include "..\lib\devModeV351.h"#include "..\lib\devModeV400.h"#include "..\lib\devModeV401.h"#include "..\lib\extDevMode.h"#include "..\lib\printResizerCommon.h"#include "..\lib\utils.h"#include <malloc.h>#include <strsafe.h>//#include <tchar.h>#include <windows.h>#include <winddi.h>#include <winddiui.h>#include <winspool.h>BOOL DrvConvertDevMode( LPTSTR lptstrPrinterName, PDEVMODE pdmIn, PDEVMODE pdmOut, PLONG pcbNeeded, DWORD fMode ) { DWORD dwcNeeded = 0; static BOOL bBreak = STATICBOOLBREAK; ASSERT(!bBreak); if (pcbNeeded == NULL) { SetLastError(ERROR_INVALID_PARAMETER); return FALSE; } switch(fMode) { case CDM_CONVERT: if (pdmOut == NULL) { SetLastError(ERROR_INVALID_PARAMETER); return FALSE; } if (pdmOut->dmSize == GetDevModeV351Size()) { pdmOut->dmSpecVersion = 0x320; } else if (pdmOut->dmSize == GetDevModeV400Size()) { pdmOut->dmSpecVersion = 0x400; } else if (pdmOut->dmSize == GetDevModeV401Size()) { pdmOut->dmSpecVersion = 0x401; } dwcNeeded = DM_GetTotalSize(pdmOut); break; case CDM_CONVERT351: dwcNeeded = GetDevModeV351Size() + pdmOut->dmDriverExtra; break; case CDM_DRIVER_DEFAULT: dwcNeeded = (DWORD) ::EXTDM_Sizeof(); break; default: SetLastError(ERROR_INVALID_PARAMETER); return FALSE; } // switch(fMode) if (*pcbNeeded < (LONG) dwcNeeded) { if (fMode == CDM_CONVERT) { SetLastError(ERROR_INVALID_PARAMETER); return FALSE; } else { *pcbNeeded = dwcNeeded; SetLastError(ERROR_INSUFFICIENT_BUFFER); return FALSE; } } if (pdmOut == NULL) { SetLastError(ERROR_INVALID_PARAMETER); return FALSE; } if (fMode == CDM_DRIVER_DEFAULT) { EXTDM_SetToDefault( (PEXTDEVMODE) pdmOut, lptstrPrinterName); } else { if (pdmIn == NULL) { SetLastError(ERROR_INVALID_PARAMETER); return FALSE; } *pcbNeeded = dwcNeeded; ConvertDevMode(pdmOut, pdmIn, fMode == CDM_CONVERT351 ); } return TRUE;} // DrvConvertDevMode
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -