BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

ShellExecute and timing delay

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (WinAPI)
View previous topic :: View next topic  
Author Message
Guest






PostPosted: Tue Apr 17, 2007 1:25 pm    Post subject: ShellExecute and timing delay Reply with quote



I have a program that is creating geotiffs that I am writing in C/C++
Borland Developer Studio 2006.

I am calling two executables - these being the freely avail TIFF
library functions...

bmp2tiff.exe (for converting a bitmap to tiff)
geotifcp.exe (for adding metadata to a tiff so it can be geocoded)

Instead of using the plain

std::system(CommandString.c_str());

call which brings up the cmd window I chose to use the

ShellExecute

call of which I assume I have more control and can set the nShowCmd =
SW_HIDE so as to not have the cmd window pop up.

Now - I guess my first fault may lay here in that Im not aware of any
way of using the std::system call AND being able to suppress the cmd
window from popping up - so I chose the ShellExecute function.

The problem I had with using ShellExecute was that in calling both
executables (bmp2tiff.exe and geotifcp.exe) consecutively - I had to
write my own delay function after each one to ensure the programs had
fully converted the bmp/tiff files AND wrote them to hard disk.

I found that if there was no delay function - even though the
ShellExecute calls worked fine (return succes code 32) I would get
problems with invalid files being fed into the next exe (i.e. the tiff
to be the input file to geotifcp was prob still open and hadnt been
closed - geotifcp would then only produce an errornous empty tiff
file).

For instance, the output tiff of bmp2tiff.exe was fed into
geotifcp.exe and it appears that bmp2tiff.exe didnt have enough time
to fully convert and write the file to disk and close the file before
geotifcp.exe went to open it and add metadata. I worked out that it
was a timing issue, as if i stepped thru the code in debug mode it
worked fine, but when it went to run by itself, I came up with timing
problems.

What methods (other than my delay) could I use to monitor the fact
that the exe's have finished and closed the files? as the only return
from ShellExecute that i kept getting was succes value 32.

having read this blog http://blogs.msdn.com/oldnewthing/archive/2006/05/05/590749.aspx
my issue i had with ShellExecute is kind of along the same lines...

p.

ps - the delay i used was a while loop. knowing what size the output
files should be from the exe's (bmp2tiff.exe and geotifcp.exe) i ran
a while loop with a function inside to check thier respective sizes
untill they where correct... and it worked (dodgy sounding i know!).
Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (WinAPI) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.