From: dpb on
rrr7rrr(a)gmail.com wrote:
....
> Thanks and e p c & dpb for taskkill idea, it works fine.

No problem... :)

> My code writes to the disk the list of PIDs, ...
>
....
> I couldn't find WinAPI function which gathers all windows handles
> and tells what program it belongs to.

The utility does and at one time I had source for a similar utility;
unfortunately, it didn't seem to get to the new machine (or at least I
can't find it at the moment). :(

I don't recall how that was done precisely; I'll try to look on the old
machine and see if I can locate that.

A search on MSDN might uncover the jewel if you're really interested.

--
From: dpb on
dpb wrote:
....

> I don't recall how that was done precisely; I'll try to look on the old
> machine and see if I can locate that.
....

Unfortunately, I didn't find the source for the old utility but I looked
in the executable for the tskill utility on this XP machine. The magic
appears to be in the following --

WinStationTerminateProcess
WinStationEnumerateProcesses
WinStationFreeGAPMemory
WinStationGetAllProcesses
WinStationOpenServer
WINSTA.dll

--
From: Gary Scott on
rrr7rrr(a)gmail.com wrote:
> On Jun 14, 11:52 pm, e p chandler <e...(a)juno.com> wrote:
>
>>On Jun 14, 12:13 pm, dpb <n...(a)non.net> wrote:
>>Vista (& XP pro?) also has TASKLIST.
>>
>>Sysinternals (now part of MS) has "Process Explorer". Among other
>>things this utility has an option to list which process has a
>>particular file open. IIRC this question came up in this newsgroup
>>recently WRT Linux.
>>
>>- e
>
>
> Thanks and e p c & dpb for taskkill idea, it works fine.
>
> My code writes to the disk the list of PIDs, then finds there needed
> one
> based on its name supplied as external parameter to exe file when
> you call it, and finally just kills the process.
> All in Fortran, 40 lines total (mostly text manipulation to find PID).
>
> Unfortunately i was not able to realise Garry Scott's suggestion.
> Garry, do you have a code which gets process ID?
> I couldn't find WinAPI function which gathers all windows handles
> and tells what program it belongs to.

Not handy, but I searched and found many examples via google. If the
command line options are acceptable, by all means go that route. I only
meant to mention that it was less portable than using the API (but much
easier).

--

Gary Scott
mailto:garylscott(a)sbcglobal dot net

Fortran Library: http://www.fortranlib.com

Support the Original G95 Project: http://www.g95.org
-OR-
Support the GNU GFortran Project: http://gcc.gnu.org/fortran/index.html

If you want to do the impossible, don't hire an expert because he knows
it can't be done.

-- Henry Ford
From: Jugoslav Dujic on
rrr7rrr(a)gmail.com wrote:
| On Jun 14, 11:52 pm, e p chandler <e...(a)juno.com> wrote:
|| On Jun 14, 12:13 pm, dpb <n...(a)non.net> wrote:
|| Vista (& XP pro?) also has TASKLIST.
||
|| Sysinternals (now part of MS) has "Process Explorer". Among other
|| things this utility has an option to list which process has a
|| particular file open. IIRC this question came up in this newsgroup
|| recently WRT Linux.
||
|| - e
|
| Thanks and e p c & dpb for taskkill idea, it works fine.
|
| My code writes to the disk the list of PIDs, then finds there needed
| one
| based on its name supplied as external parameter to exe file when
| you call it, and finally just kills the process.
| All in Fortran, 40 lines total (mostly text manipulation to find PID).
|
| Unfortunately i was not able to realise Garry Scott's suggestion.
| Garry, do you have a code which gets process ID?
| I couldn't find WinAPI function which gathers all windows handles
| and tells what program it belongs to.

The following APIs might be of help:

FindWindow or EnumWindows (to get the window handle by name or whatever)
GetWindowThreadProcessId (to get the PID by HWND)
OpenProcess (to get the HPROCESS by PID)
TerminateProcess (well, obviously)

--
Jugoslav
___________
www.xeffort.com

Please reply to the newsgroup.
You can find my real e-mail on my home page above.