Link to home
Start Free TrialLog in
Avatar of beezee
beezeeFlag for Australia

asked on

CreateProcess and WaitForSingleObject fails on the second of two PDF files

All
I use CreateProcess and WaitForSingleObject in Delphi 2007 to open files and wait for them to be closed.
I have found that when I open two PDF files in a row, the second WaitForSingleObject returns immediately. I have also found that this happens for jpg and tif files but not txt files. Also the second PDF takes 10 seconds longer to open than if opened by itself!
It also happens on both Vista and XP, and on a range of computers.
Am I using CreateProcess incorrectly or is it something else?

Any help would be appreciated.

Regards

Bob

if CreateProcess(nil, PChar(sText), nil, nil, False,
    NORMAL_PRIORITY_CLASS, nil, pFilePath, myStartupInfo, myProcessInfo) then begin
    WaitForSingleObject(myProcessInfo.hProcess, INFINITE);
    CloseHandle(myProcessInfo.hProcess);
    CloseHandle(myProcessInfo.hThread);
end;

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of ahalya
ahalya
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of beezee

ASKER

ahalya
Thanks for that. I added the /n switch to Acro32.exe and it solved the problem.

Regards

Bob