tags:

views:

121

answers:

2

I'm printing using CreateDC, passing in a valid DEVMODE structure and getting NULL returned which indicates an error but GetLastError returns 0.

m_hDC = ::CreateDC(L"WINSPOOL", PrinterName, NULL, pDevMode);
if (m_hDC == NULL)
{
 throw Exception(GetLastError(), __LINE__, _T(__FILE__));
}

This is working for all of my customers apart from one, any ideas?

A: 

Are you sure that pDevMode is valid? You could try using a NULL pointer here in case the DEVMODE is the issue.

Rob
It fails with NULL as well.
Tony Edgecombe
+1  A: 

This turned out to be a problem with the thunking spooler api's.

The software is a 32 bit Windows service running on a 64 bit system.

It seems that only one user/session can print at a time from a 32 bit process, the next user has to wait for splwow64.exe to timeout (or kill it) before they can print.

It is covered in a technote from MS.

Tony Edgecombe