Access to DEVMODE private members from StartDocPort

Hi all,

currently I am trying to implement a printer port monitor DLL and a printer UI plugin using the IPrintOemUI interface (as shown in “localmon” and “OEMUI” example from DDK). I am using these plug ins with the default postscript driver.

Some facts in advance:
As you might know the OEMUI example plugin adds a printer property sheet and an OPITEM to the configuration dialog (it is labeled with “OEM UI Added
item”). The data of this item is stored as additional data to DEVMODE struct (“dwDriverData” of OEMDEV struct in devmode.h and devmode.cpp).

I am using DEVMODE struct to store the data from user for additional data members in my printer UI plugin (that is how it is done in OEMUI example, so I did it the same way). My problem is, that I am not able to read out my private UI plugin members in DEVMODE structure from within the printer port monitor DLL. I am pretty sure I am doing something wrong, when I try to get DEVMODE from printer port monitor’s “StartDocPort” function. Here is how I tried to get access to DEVMODE from StartDocPort:

//---------------------------------------------

//…

if (OpenPrinter(pPrinterName, &pIniPort->hPrinter, NULL)) {
HANDLE hFile = INVALID_HANDLE_VALUE;

// Get pointer to DEVMODE structure by calling GetJob
dwNeeded = 0;
GetJob(pIniPort->hPrinter, JobId, 2, NULL, 0, &dwNeeded);
Error = GetLastError();
if ( Error != ERROR_INSUFFICIENT_BUFFER && Error != ERROR_SUCCESS ) {
MY_VERBOSE1(TEXT(“First call GetJob failed. (%d)”), Error);
goto Fail;
}

if ( !(pJobInfo = (LPJOB_INFO_2) AllocSplMem(dwNeeded)) ||
!GetJob(pIniPort->hPrinter, JobId, 2, (LPBYTE)pJobInfo, dwNeeded, &dwNeeded)) {
Error = GetLastError();
MY_VERBOSE1(TEXT(“Second call GetJob failed. (%d)”), Error);
goto Fail;
}

// We should have a JobInfo here

if(!pJobInfo) {
MY_VERBOSE0(TEXT(“JobInfo is NULL.”));
goto Fail;
}

if(!pJobInfo->pDevMode) {
MY_VERBOSE0(TEXT(“JobInfo Devmode is NULL.”));
goto Fail;
}

// Trace sizes - both (dmDriverExtra and dmSize) seem to be filled correctly here
MY_VERBOSE2(TEXT(“Devmode extra size = %d, dmSize = %d”), pJobInfo->pDevMode->dmDriverExtra, pJobInfo->pDevMode->dmSize );

// Moving pointer to correct position in data
pUIData = (OEMDEV*)(((LPBYTE)pJobInfo->pDevMode) + (pJobInfo->pDevMode->dmSize));
if(!pUIData) {
MY_VERBOSE0(TEXT(“pUIData == NULL!!”));
goto Fail;
}

// Trace values
MY_VERBOSE1(TEXT(“dmCopies: %d”), pJobInfo->pDevMode->dmCopies); // This member is set correctly
MY_VERBOSE1(TEXT(“dwDriverData: %d”), pUIData->dwDriverData); // This member is part of the private data and it is NOT set

correctly

// …
}

//---------------------------------------------

As you can see, I am trying to get the DEVMODE data by calling GetJob. I am trying to use the internal DEVMODE of JOB_INFO_2 data returned by this call.

But that is not working: The default parts of the DEVMODE struct seems to be OK, e.g. if I change copy count in notepad and start printing, the value is appearing correctly in my traces, but if I change the value of my dwDriverData it is not set in my traces (but according to my traces in the UI Plugin the data is set correctly inside the UI DLL).

My questions:

1.) In general: Is it possible to read out private data members, filled by a printer UI plugin (like variable “dwDriverData” in OEMUI example) in (or better “behind”) the DEVMODE structure, from within a port monitor DLL? If the answer is no: How can I do it?

2.) If the answer to the first question is yes: Is “my way” the “right way” to do this?

I hope my explanation is clear enough - feel free to ask for details if something is missing. Thanks in advance for any replies to this topic.

Greetings.
Pat

Ist Ihr Browser Vista-kompatibel? Jetzt die neuesten
Browser-Versionen downloaden: http://www.gmx.net/de/go/browser