Re: Processes: Threads ?????

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Tom Esh (tjeshGibberish_at_earthlink.net)
Date: 02/28/04


Date: Sat, 28 Feb 2004 15:57:03 -0500

On Sat, 28 Feb 2004 13:59:21 -0500, "JonWayn" <jongunn@bellsouth.net>
wrote:

> DazTask = ShellExecute(hDade, vbNullString, DazzleExePath, 0&,
>DazzlePath, SW_MINIMIZE)
> DoEvents
> hDade = Application.hWndAccessApp 'Get Dade application
>hwnd
> SetForegroundWindow (hDade) 'Set focus to Dade
> hAThread = GetWindowThreadProcessId(hDade, hAProcess)
>
>
>
>Just so I understand threads and processes a little more: I was reviewing my
>own codes (above) a little while ago, after learning that a process is
>basically an application and a thread is just any unit that requires
>processing attention, and also that the GetWindowThreadProcessId function
>gets the thread that owns the window indicated by its hwnd argument, and the
>process that created the window. I placed a break mark at the statement
>following the last statement above, just to see what the function would
>return in these 2 variables. I thought that since I opened this application
>from the user interface, then there shouldnt be any process that created the
>window - I was wrong: a non-zero value was returned for the process. Can
>someone make it clearer, what exactly is that process variable
>identifying? - what application? When I click to launch the app, what is the
>chain of events that took place prior to the actual opening of the window,
>with regards to the owner process and thread?
>
>I hope someone sees where I'm coming from and I didn't confuse the heck out
>of all of you!

On return, the variable you pass in the 2nd parameter of
GetWindowThreadProcessId is populated with the ID of the process that
owns the thread that owns the window. The return value is the ID of
the thread that owns the window.

Maybe this will help. The heirarchy is:
Process
        Thread(s) belonging to the process
                Window(s) belonging to a thread

1) A thread must belong to a process.
2) A window must belong to a thread (and therefore indirectly must
belong to a process).
3) A process ~must~ have at least one thread
4) A thread ~can~ exist without any windows, though in the case of a
VB app, the VB runtime always creates at least one non-visible window.

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



Relevant Pages

  • Re: keyboard events for different CWnds
    ... different messages in the window that they belong to. ... If I have a MDI application and therein certain Key strokes 'belong' to ... the mainframe and others to the child frame and perhaps certain others ... MainFrame) and Ctrl+C copies content in the child window (message goes ...
    (microsoft.public.vc.mfc)
  • Re: getwindowtext() api for password mask ...
    ... Make a global hook: Is this way as the hook resides in a dll that get loaded in every process you can send the WM_GETTEXT message from within the same process that the window belong. ...
    (borland.public.delphi.nativeapi)
  • Re: Problem with Window.Close()
    ... the winow is not belong to me. ... But when i open few IE browser, ... >> I'm using window.close() to close the window. ... The window where your entry page opens is not yours. ...
    (microsoft.public.scripting.jscript)
  • Re: Choice between CMOS 4099 or 74HC259
    ... since 4099 belong to ice age now. ... just like window 3.1 and 95. ... Prev by Date: ...
    (comp.arch.embedded)
  • Re: Steve Carroll does not know the difference between saving and quitting.
    ... or in an app where it can be used for additional work it ... Most apps cannot be used with no window open... ... yet it does not quit. ... And nor should it Snit! ...
    (comp.sys.mac.advocacy)