Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

CreateProcess and WaitForSingleObject fails on the second of two PDF files

Posted on 2009-04-14
2
Medium Priority
?
554 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering 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

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…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Suggested Courses

636 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