Я использовал код, предоставленный самой Microsoft (Как изменить настройки принтера с помощью функции DocumentProperties ()) , чтобы изменить некоторые настройки для принтера: однако, работая как драйверы для PCL, драйверы PSКажется, у него есть более индивидуальное ощущение того, что использовать и что игнорировать.Следующий код скомпилирован с VC 2017 на 64-битной Windows 10, используются следующие драйверы:
- Fiery MS MIC-4150 PS1.1
- Цветной лазерный принтер Konica Minolta PS Color
- Konica Minolta 1200/1051 PCL
- Microsoft Print To PDF
- Принтер класса Microsoft PS
Точнее, «ориентация» кажетсяПринято всеми драйверами, «дуплекс» не принимается никем, кроме драйвера PCL.Нужно сказать, что, несмотря на неспособность изменить настройки через структуру DEVMODE, все это можно изменить с помощью диалогов, поставляемых поставщиком.
{
HANDLE hPrinter;
LPDEVMODE pDevMode;
DWORD dwNeeded, dwRet;
/* Start by opening the printer */
if (!OpenPrinter(pDevice, &hPrinter, NULL))
return NULL;
/*
* Allocate a buffer of the correct size.
*/
dwNeeded = DocumentProperties(NULL,
hPrinter, /* Handle to our printer. */
pDevice, /* Name of the printer. */
NULL, /* Asking for size, so */
NULL, /* these are not used. */
0); /* Zero returns buffer size. */
pDevMode = (LPDEVMODE)malloc(dwNeeded);
/*
* Get the default DevMode for the printer and modify it for your needs.
*/
dwRet = DocumentProperties(NULL,
hPrinter,
pDevice,
pDevMode, /* The address of the buffer to fill. */
NULL, /* Not using the input buffer. */
DM_OUT_BUFFER); /* Have the output buffer filled. */
if (dwRet != IDOK)
{
/* If failure, cleanup and return failure. */
free(pDevMode);
ClosePrinter(hPrinter);
return NULL;
}
assert(pDevMode->dmFields & DM_ORIENTATION);
assert(pDevMode->dmFields & DM_DEFAULTSOURCE);
assert(pDevMode->dmFields & DM_COPIES);
assert(pDevMode->dmFields & DM_DUPLEX);
assert(pDevMode->dmFields & DM_COLOR);
pDevMode->dmCopies = 4711;
pDevMode->dmDuplex = DMDUP_VERTICAL;
pDevMode->dmColor = DMCOLOR_MONOCHROME;
pDevMode->dmOrientation = DMORIENT_LANDSCAPE;
pDevMode->dmFields = DM_COLOR | DM_DUPLEX | DM_COPIES | DM_ORIENTATION;
/*
* Merge the new settings with the old. This gives the driver an opportunity to update any private portions of the DevMode structure.
*/
dwRet = DocumentProperties(NULL,
hPrinter,
pDevice,
pDevMode, /* Reuse our buffer for output. */
pDevMode, /* Pas the driver our changes. */
DM_PROMPT | DM_IN_BUFFER | /* Commands to Merge our changes and */
DM_OUT_BUFFER); /* write the result. */
/* Finished with the printer */
ClosePrinter(hPrinter);
if (dwRet != IDOK)
{
/* If failure, cleanup and return failure. */
free(pDevMode);
return NULL;
}
/* Return the modified DevMode structure. */
return pDevMode;
}
Есть ли у кого-нибудь более четкое представление оэта история?Спасибо.