pdf only printing first time in multithreaded service

Black Ice Printer Driver related questions

Moderator: Technical Support Team

pdf only printing first time in multithreaded service

Postby jvshore » Sun Oct 24, 2010 3:12 am

Using the BiAutoPrint.dll to print from a multithreaded service, pdf files only print the first time requested (the rest of the jobs don't complete successfully). I have determined that this is due to the process AcroRD32.exe has not exited (or closed its window). The code is attempting to find the window Adobe Reader to issue a close command (or destroy command). I am using Adobe Reader 9. What window should FindWindow be looking for - obviously Adobe Reader is not the correct window.
jvshore
 
Posts: 16
Joined: Tue Sep 21, 2010 12:27 pm

Re: pdf only printing first time in multithreaded service

Postby jvshore » Mon Oct 25, 2010 10:56 am

I found the problem and made the fix to the library. I removed the closeacrobat method and issued the call to findwindow after the shellexecute call:

sprintf(szParam, "/p /h \"%s\"", pFileName);

HANDLE hAcrobatMutex = OpenMutex(MUTEX_ALL_ACCESS, FALSE, _T("6EABA18D-7D01-4b04-9F71-073FFDF295E6"));
WaitForSingleObject(hAcrobatMutex, INFINITE);
try
{
ShellExecuteA(NULL, "open", szExePath, szParam, NULL, 0);
bool winFound = false;
while(true)
{
HWND hwnd = ::FindWindowEx(NULL, NULL, _T("AcrobatSDIWindow"), _T("Adobe Reader"));
if(hwnd)
{
::SendMessage(hwnd, WM_CLOSE, 0, 0);
winFound = true;
} else if(winFound)
break;

Sleep(100);
}

ReleaseMutex(hAcrobatMutex);
} catch(...)
{
ReleaseMutex(hAcrobatMutex);
}
jvshore
 
Posts: 16
Joined: Tue Sep 21, 2010 12:27 pm


Return to Printer Drivers



Who is online

Users browsing this forum: No registered users and 0 guests