Board index » delphi » Createprocess versus shellexecute

Createprocess versus shellexecute

Hi people,

Some people may have seen some earlier postings regarding this subject. MH
Avegaart gave me some
great information, which worked and is still working fine! RECAP = My
program, at regular intervals (based upon a timer), scans a specific
directory for certain types of files. (i.e. files with extensions that start
with the '%' char). When it finds one it looks at the file extension to
determine which network printer it is to be distributed to. During the
actual 'sending to a printer' routine, which includes the createprocess, the
program calls a batch file to instigate a network dos command.

The batch file itself , from a windows p.o.v., runs as minimised. Its dos
window 'flashes' on and off the task bar (i.e. opens and closes the dos
window very quickly) and appears to do the same for the desktop, especially
when other windows are open.

There is one other minor point. The interval timer is set at 1000
millisecs.So, each second it scans for a file.
If the program finds a large collection of files, it would be 'tied up' for
quite a while. So, to remedy this somewhat I've put a
Application.ProcessMessages command inside the 'scanning routine'. This
appears to be a bit cumbersome

Question1 : How can I stop this apparent 'flashing' ?
Question 2: Is there another way of getting my program to allow windows
messages/events other than using
Application.ProcessMessages? Would the use of threads be more efficient?

Thank you for any help given (TIA)

Gaz

 

Re:Createprocess versus shellexecute


On Tue, 6 Mar 2001 08:06:18 -0000, "Garry Charles"
<ga...@eltons.co.uk> waffled on about something:

Quote
>Hi people,

>Some people may have seen some earlier postings regarding this subject. MH
>Avegaart gave me some
>great information, which worked and is still working fine! RECAP = My
>program, at regular intervals (based upon a timer), scans a specific
>directory for certain types of files. (i.e. files with extensions that start
>with the '%' char). When it finds one it looks at the file extension to
>determine which network printer it is to be distributed to. During the
>actual 'sending to a printer' routine, which includes the createprocess, the
>program calls a batch file to instigate a network dos command.

>The batch file itself , from a windows p.o.v., runs as minimised. Its dos
>window 'flashes' on and off the task bar (i.e. opens and closes the dos
>window very quickly) and appears to do the same for the desktop, especially
>when other windows are open.

>There is one other minor point. The interval timer is set at 1000
>millisecs.So, each second it scans for a file.
>If the program finds a large collection of files, it would be 'tied up' for
>quite a while. So, to remedy this somewhat I've put a
>Application.ProcessMessages command inside the 'scanning routine'. This
>appears to be a bit cumbersome

>Question1 : How can I stop this apparent 'flashing' ?
>Question 2: Is there another way of getting my program to allow windows
>messages/events other than using
>Application.ProcessMessages? Would the use of threads be more efficient?

>Thank you for any help given (TIA)

>Gaz

If memory serves me right, there is an API call in windows you can use
to say you want to know of any changes to a directory....
You provide it with a callback routine, and when something changes it
tips you the wink....

I stumbled across is completely by accident, but never used it, I'll
go and have a stumble again and try and find what it's called.

Dodgy.

Re:Createprocess versus shellexecute


The functions are FindFirstChangeNotification, FindNextChangeNotification
and FindCloseChangeNotification, see the Win32 Programmer's Reference
(win32.hlp). These functions will lock the calling thread, so if you want to
keep your application responding you will have to call these functions from
a separate thread.

"Dodgy" <Do...@earth.planet.universe> schreef in bericht
news:bfl9atsn3b6lk368k1e48rlspv515t17ui@4ax.com...
...

Quote

> If memory serves me right, there is an API call in windows you can use
> to say you want to know of any changes to a directory....
> You provide it with a callback routine, and when something changes it
> tips you the wink....

> I stumbled across is completely by accident, but never used it, I'll
> go and have a stumble again and try and find what it's called.

> Dodgy.

Re:Createprocess versus shellexecute


I knew if we waited a couple of minutes the great oracle would
surface...

Thanks M.H.

On Tue, 6 Mar 2001 14:31:51 +0100, "M.H. Avegaart"
<avegaartNOS...@mccomm.nl> waffled on about something:

Quote
>The functions are FindFirstChangeNotification, FindNextChangeNotification
>and FindCloseChangeNotification, see the Win32 Programmer's Reference
>(win32.hlp). These functions will lock the calling thread, so if you want to
>keep your application responding you will have to call these functions from
>a separate thread.

>"Dodgy" <Do...@earth.planet.universe> schreef in bericht
>news:bfl9atsn3b6lk368k1e48rlspv515t17ui@4ax.com...
>...

>> If memory serves me right, there is an API call in windows you can use
>> to say you want to know of any changes to a directory....
>> You provide it with a callback routine, and when something changes it
>> tips you the wink....

>> I stumbled across is completely by accident, but never used it, I'll
>> go and have a stumble again and try and find what it's called.

>> Dodgy.

Re:Createprocess versus shellexecute


Eh ?...you guys are losing me !!

thank you very much ..I shall go away, even though I do not understand
these, I shall
study the help files and try to get a good idea what it's all about ......

Quote
M.H. Avegaart <avegaartNOS...@mccomm.nl> wrote in message

news:982ot8$gbl$1@porthos.nl.uu.net...
Quote
> The functions are FindFirstChangeNotification, FindNextChangeNotification
> and FindCloseChangeNotification, see the Win32 Programmer's Reference
> (win32.hlp). These functions will lock the calling thread, so if you want
to
> keep your application responding you will have to call these functions
from
> a separate thread.

> "Dodgy" <Do...@earth.planet.universe> schreef in bericht
> news:bfl9atsn3b6lk368k1e48rlspv515t17ui@4ax.com...
> ...

> > If memory serves me right, there is an API call in windows you can use
> > to say you want to know of any changes to a directory....
> > You provide it with a callback routine, and when something changes it
> > tips you the wink....

> > I stumbled across is completely by accident, but never used it, I'll
> > go and have a stumble again and try and find what it's called.

> > Dodgy.

Other Threads