SHELL Command Returns Task ID...How Can I Close The Task 
Author Message
 SHELL Command Returns Task ID...How Can I Close The Task

I have been using Access 2.0 as a report 'Server'.  It has a routine that
allows me to queue up my requests and then launch the application.  When
launched, the reports are opened in preview mode.  

Problem:  I use the SHELL command to open Access with a command line.  The
SHELL function returns an ID number which can be used with the AppActivate
command to re-establish focus from other points in the program.

How can I close this stand-alone instance of Access.  I have tried looking
for an API call, including CloseWindow and DestroyWindow, that I could use.
 What I need is an equivalent to AppDeActivate.  

Any ideas?

tia

Rob





Fri, 04 Aug 2000 03:00:00 GMT  
 SHELL Command Returns Task ID...How Can I Close The Task

Yes, I use the Kill.exe From The ntreskit... I shell out Kill <PID#> and
Done... Finished clean Kill...  But i know that you probably want
everything in one complete package...  I dont know otherwize...  But it
might help out for now...  

--
Thanks David L. Gorman
MCSE, MCP + Internet, A+, 3Com, Hp, IBM, and Compaq Certified

AutoMation Programmer/Programmer
CompuCOM Systems Incorp.
1-609-224-5149
http://www.jersey.net/~polarbear/SIG.HTML



Quote:
> I have been using Access 2.0 as a report 'Server'.  It has a routine that
> allows me to queue up my requests and then launch the application.  When
> launched, the reports are opened in preview mode.  

> Problem:  I use the SHELL command to open Access with a command line.
The
> SHELL function returns an ID number which can be used with the
AppActivate
> command to re-establish focus from other points in the program.

> How can I close this stand-alone instance of Access.  I have tried
looking
> for an API call, including CloseWindow and DestroyWindow, that I could
use.
>  What I need is an equivalent to AppDeActivate.  

> Any ideas?

> tia

> Rob






Sat, 05 Aug 2000 03:00:00 GMT  
 SHELL Command Returns Task ID...How Can I Close The Task

Check out Sendmessage, and postmessage APIs
WM_CLOSE
--
Donald A. Herman
Anidesk 2.0  Animated Desktop Icons
Ani and Icon Browsers
http://www.fcs-net.com/~dherman/index.htm



Quote:
> I have been using Access 2.0 as a report 'Server'.  It has a routine that
> allows me to queue up my requests and then launch the application.  When
> launched, the reports are opened in preview mode.  

> Problem:  I use the SHELL command to open Access with a command line.
The
> SHELL function returns an ID number which can be used with the
AppActivate
> command to re-establish focus from other points in the program.

> How can I close this stand-alone instance of Access.  I have tried
looking
> for an API call, including CloseWindow and DestroyWindow, that I could
use.
>  What I need is an equivalent to AppDeActivate.  

> Any ideas?

> tia

> Rob






Sun, 06 Aug 2000 03:00:00 GMT  
 SHELL Command Returns Task ID...How Can I Close The Task

Unfortunately, you need the hWnd in order to send a WM_CLOSE.  I don't know
of a way to get the hWnd from the process ID, unless you iterate through all
the avaliable window handles looking for a match.  The problem gets even
worse when you are shelling 16-bit apps.  Then you get the process ID of the
subsystem.  I don't know of ANY way to get the window handle to a 16-bit app
to close it once you started it.  (I guess this problem is only relevant on
NT, but it still sucks!!)

-Adam.


    Check out Sendmessage, and postmessage APIs
    WM_CLOSE
    --
    Donald A. Herman
    Anidesk 2.0  Animated Desktop Icons
    Ani and Icon Browsers
    http://www.fcs-net.com/~dherman/index.htm



    > I have been using Access 2.0 as a report 'Server'.  It has a routine
that
    > allows me to queue up my requests and then launch the application.
When
    > launched, the reports are opened in preview mode.
    >
    > Problem:  I use the SHELL command to open Access with a command line.
The
    > SHELL function returns an ID number which can be used with the
AppActivate
    > command to re-establish focus from other points in the program.
    >
    > How can I close this stand-alone instance of Access.  I have tried
looking
    > for an API call, including CloseWindow and DestroyWindow, that I could
use.
    >  What I need is an equivalent to AppDeActivate.
    >
    > Any ideas?
    >
    > tia
    >
    > Rob
    >

    >

    >



Mon, 07 Aug 2000 03:00:00 GMT  
 SHELL Command Returns Task ID...How Can I Close The Task

Once you have the ProcessID from the Shell() command, use OpenProcess API
to get the window handle.

Then you can use Terminate process API to close the app.  You must use
CloseHandle API after using TerminateProcess, to close the Thread handle
too.

Hope this helps.



Tue, 08 Aug 2000 03:00:00 GMT  
 SHELL Command Returns Task ID...How Can I Close The Task

Obtaining a Window Handle in Another Application

You must obtain a handle to a window in another application in order to
send it a message. At first glance, the FindWindow (classname$,
windowname$) API seems a suitable choice. Unfortunately, there are many
cases where it is not reliable. Finding a window by class runs into
problems any time more than one window of a class exists. For example: if
more than one instance of NotePad is running, FindWindow will return the
handle of the first one found, which may not be the one you want. The same
problem applies to doing a FindWindow based on the window name (which is
the same as the window caption), plus you have the added problem of
handling those applications who modify their caption based on the open
document. For example: the default windowname for Notepad is actually
"Notepad - (Untitled)".

The real solution for this problem is to use the EnumWindows API function
to enumerate all of the top level windows in the system, checking first if
it belongs to the module handle that you are searching for (as returned by
the Shell command or WinExec API) and also if it matches the class that you
are looking for (for cases where an application has more than one top level
window). The EnumWindows API function takes as one of its parameters a
pointer to a function.
All of the material presented here is copyrighted by either Desaware or
Macmillan. No part of this material may be used or reproduced in any
fashion (except in brief quotations used in critical articles and reviews)
without prior consent.
--
Donald A. Herman
Anidesk 2.0  Animated Desktop Icons
Ani and Icon Browsers
http://www.fcs-net.com/~dherman/index.htm



Quote:
> Unfortunately, you need the hWnd in order to send a WM_CLOSE.  I don't
know
> of a way to get the hWnd from the process ID, unless you iterate through
all
> the avaliable window handles looking for a match.  The problem gets even
> worse when you are shelling 16-bit apps.  Then you get the process ID of
the
> subsystem.  I don't know of ANY way to get the window handle to a 16-bit
app
> to close it once you started it.  (I guess this problem is only relevant
on
> NT, but it still sucks!!)

> -Adam.


>     Check out Sendmessage, and postmessage APIs
>     WM_CLOSE
>     --
>     Donald A. Herman
>     Anidesk 2.0  Animated Desktop Icons
>     Ani and Icon Browsers
>     http://www.fcs-net.com/~dherman/index.htm



>     > I have been using Access 2.0 as a report 'Server'.  It has a
routine
> that
>     > allows me to queue up my requests and then launch the application.
> When
>     > launched, the reports are opened in preview mode.

>     > Problem:  I use the SHELL command to open Access with a command
line.
> The
>     > SHELL function returns an ID number which can be used with the
> AppActivate
>     > command to re-establish focus from other points in the program.

>     > How can I close this stand-alone instance of Access.  I have tried
> looking
>     > for an API call, including CloseWindow and DestroyWindow, that I
could
> use.
>     >  What I need is an equivalent to AppDeActivate.

>     > Any ideas?

>     > tia

>     > Rob






Tue, 08 Aug 2000 03:00:00 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. Hiding Task ID in Task List

2. Program ID does not appear in Task Bar and Task List

3. Test for Task/shell Completion via an ID?

4. shell and task ID check

5. meaning of "Shell"'s task ID

6. Shell Function: task ID

7. Program ID vs. Task ID

8. After closing my application, Task is active an will not close

9. How to Create Task Item in Someone Else's Task Folder

10. Adding tasks to a named task list

11. Task and Task Request

12. Keep updated copy of this task on my task list

 

 
Powered by phpBB® Forum Software