by 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);
}