Article View: borland.public.cppbuilder.nativeapi
Article #1593Service spawns Process - EnumWindows problem
From: Paul
Date: Fri, 20 Jul 2007 12:05
Date: Fri, 20 Jul 2007 12:05
46 lines
2288 bytes
2288 bytes
--
Hi,
We have a service-started automatically on system startup to
-Start Process A
-Start process B
-Start process Guardian.
the service then terminates.
Each of the above is started with
if (CreateProcess(NULL, process_name.c_str(), NULL, NULL, FALSE,
NORMAL_PRIORITY_CLASS, NULL, NULL, &startup_info, &process_info[0]))
{...}
Using Windows Messaging
- RegisterWindowMessage
- EnumWindows to get the required handle
- then PostMessage
At this point EnumWindows can find the required handle from the process
id. There may or may not be a user logged on at this point - it makes
no difference to the following outcomes.
The messaging problem starts when a process stops and is subsequently
restarted by the guardian, using CreateProcess(..as above..)
Using the SysInternals Process Explorer and debug output from the
Guardian I can see that the Guardian has the correct process id for the
restarted process.
Problems
1. EnumWindows does not have this process id in the list returned when
trying to get the new window handle to use, so no messaging is possible
withou a valid handle.
2.Manually entering the windows handle of the restarted process into
the guardian and using PostMessage - The restarted process does not see
the message.
Anyone have some clues on what I am doing wrong ?
cheers
paul
Technical Details
Message-ID:
<46a0a522$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!feeder3.cambrium.nl!feed.tweaknews.nl!newsfeed0.kamp.net!newsfeed.kamp.net!newsfeed.freenet.de!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,b7dc9abb756c9528,start X-Google-Attributes: gid10cc67,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit From: "Paul" <camrad@internode.on.net> Subject: Service spawns Process - EnumWindows problem Newsgroups: borland.public.cppbuilder.nativeapi User-Agent: XanaNews/1.18.1.6 MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 X-Antivirus: avast! (VPS 000758-0, 19/07/2007), Outbound message X-Antivirus-Status: Clean NNTP-Posting-Host: 59.167.72.184 Message-ID: <46a0a522$1@newsgroups.borland.com> Date: 20 Jul 2007 05:05:54 -0700 X-Trace: newsgroups.borland.com 1184933154 59.167.72.184 (20 Jul 2007 05:05:54 -0700) Lines: 48 Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!feeder3.cambrium.nl!feed.tweaknews.nl!newsfeed0.kamp.net!newsfeed.kamp.net!newsfeed.freenet.de!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail