Re: VB6 Restore Minimized Window - External Application

From: Tom Esh (tjeshGibberish_at_earthlink.net)
Date: 10/05/04


Date: Tue, 05 Oct 2004 07:58:02 -0400

On Tue, 5 Oct 2004 10:51:38 +0100, "Andrew Dunn"
<andrewd@cclXXXmenzies.com> wrote:

>
>I know the EXE name of the application that I want to call. I have no method
>of predicting what the form.caption will be.
>
>I have worked around this problem for now by amending the applications that
>will be called so that they write their current caption to a registry key.
>My calling program now uses the EXE name to retreive the registry key and
>then I can find my window handle.
>
>Knowing the EXE name and knowing that only one copy of the EXE will be
>running, given that I can identify the process, is there anyway of finding
>out the caption ?
>
>I will look at the FindPart example - though I suspect that I already have
>most of the code - i.e. I can already find a partial caption.

Offhand the only way I know would be to enumerate the running
processes with...
        CreateToolhelp32Snapshot
        Process32First
        Process32Next
...until you find one with the correct exename. Stash the process ID
from that, then enumerate the top-level windows with EnumWindows until
you get one who's PID matches.

Of course if your app is launching the exe, VB's shell or several Api
methods can provide the PID at that time, and you could skip the
process enumeration part.

-Tom
MVP - Visual Basic
(please post replies to the newsgroup)



Relevant Pages

  • Re: ShellExecute
    ... >> (GetProcessID), then enumerate the processes ... > CreateToolhelp32Snapshot won't return a full path to the EXE under the ... > NT kernel, just the exe name. ...
    (microsoft.public.vb.general.discussion)
  • Re: Is it running?
    ... Michael Hesse wrote: ... And what is the name you know, the exe? ... Basically you can enumerate all processes in the system and then ... I do not respond to top-posted replies, ...
    (microsoft.public.vc.language)
  • Re: Getting class names with the API?
    ... enumerate the subclasses of an IWbemServices object? ... in an EXE. ...
    (microsoft.public.win32.programmer.wmi)
  • Re: Finding Full Path to Process EXE
    ... I would like to write a script that would enumerate all running ... processes and return the full path to the EXE of each running ... (You want the .ExecutablePath or .CommandLine attributes I imagine) ...
    (comp.lang.python)
  • Re: How to get Excel / Word (MS-Office) Version ?
    ... I'd stick with trying to instantiate Excel, ... Knowing the exe is on the machine is, ... most simple and easy way except for the finding of the exe file. ...
    (microsoft.public.fox.programmer.exchange)