[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

CreateProcess and WaitForSingleObject fails on the second of two PDF files

Posted on 2009-04-14
2
Medium Priority
?
557 Views
Last Modified: 2012-05-06
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

0
Comment
Question by:beezee
2 Comments
 
LVL 7

Accepted Solution

by:
ahalya earned 1500 total points
ID: 24175000
I guess what probably is happening is that your second call creates a second instance of Acrobact Reader, which is terminating immediately  (once it figures out a previous instance is running). The second instance probably is passing the file name to the first instace of the Acrobat Reader which opens the file (but is a separate process).

Your wait returns when the second process is terminated after passing the filename

0
 

Author Closing Comment

by:beezee
ID: 31570197
ahalya
Thanks for that. I added the /n switch to Acro32.exe and it solved the problem.

Regards

Bob
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Screencast - Getting to Know the Pipeline
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Suggested Courses
Course of the Month19 days, 16 hours left to enroll

872 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question