|
-
May 6th, 2009, 09:57 AM
#1
How to hide/show running process.
I have a situation where I launch several processes from a program using CreateProcess() function.
At one time, I have to access all these processes, one by one and tell them to hide/show (minimize/maximize). Is there a way to do it? I'm looking something like what I use to terminate the processes.
Like this:
Code:
int numHandlers = this->vProcessInformations.size();
for (int c=0;c<numHandlers ;c++)
{
PROCESS_INFORMATION *pInfo = NULL;
pInfo = this->vProcessInformations[c];
HANDLE handle = pInfo->hProcess;
DWORD exitCode = NULL;
bool bRet = false;
DWORD lastError;
bRet = GetExitCodeProcess(handle,&exitCode);
lastError = GetLastError();
TerminateProcess(handle,(UINT)exitCode);
CloseHandle(handle);
delete pInfo;
}
I currently use IPC using mail slots to send command messages to other processes where each process creates mail slot handle unique to it from start parameters so I can access them all.
But this has many flaws in it since I iterate through processes very fast, not all processes get the message sent.
I basically need fast and reliable technique that will iterate through processes (created by myself) and send them commands to execute.
Any recommendations on this topic?
Thanks.
You just divided by zero, didn't you?
-
May 6th, 2009, 04:00 PM
#2
Re: How to hide/show running process.
But this has many flaws in it since I iterate through processes very fast, not all processes get the message sent.
I basically need fast and reliable technique that will iterate through processes (created by myself) and send them commands to execute.
I'm not sure I understand you entirely, but from what I do my first reaction is about the messages that get lost.
Messages can be datagrams (not guaranteed) or connection based information (which is supposedly guaranteed).
Datagrams are commonly used, but you aren't certain things arrive. You would have to deploy an acknowledgment / retry concept.
How about RPC? Seems like what you're talking about....
On the other hand, if you prefer a message based approach, why are the messages being lost? Your statement suggests it's the speed of your process loop, but I have nothing to go on there...
Are these processes in remote computers? If they're all in the same OS, can you use memory mapped files to share some RAM, creating a circular queue system, along with waitable objects you can signal (named mutexes for example). That's fast - not message based, but 'signal' based.
For that matter, if all of this is in the same machine, would you object to passing around handles in post messages directly to these other tasks? That's fast.
If my post was interesting or helpful, perhaps you would consider clicking the 'rate this post' to let me know (middle icon of the group in the upper right of the post).
-
May 7th, 2009, 10:16 AM
#3
Re: How to hide/show running process.
If you mean show/hide the window that belongs to the process, you could try to send message to the main thread of the processes.
PostThreadMessage(pInfo->dwThreadId, WM_SHOWWINDOW, TRUE/FALSE, 0);
-
May 8th, 2009, 02:42 AM
#4
Re: How to hide/show running process.
 Originally Posted by JVene
I'm not sure I understand you entirely, but from what I do my first reaction is about the messages that get lost.
Messages can be datagrams (not guaranteed) or connection based information (which is supposedly guaranteed).
Datagrams are commonly used, but you aren't certain things arrive. You would have to deploy an acknowledgment / retry concept.
How about RPC? Seems like what you're talking about....
On the other hand, if you prefer a message based approach, why are the messages being lost? Your statement suggests it's the speed of your process loop, but I have nothing to go on there...
I'm using IPC mail slot system to send/receive messages. As described here
http://msdn.microsoft.com/en-us/libr...ilslot_for_ipc
GetLastError() on creation of mailslots sometimes return 183 which means that file (mailslot) already exists.
 Originally Posted by JVene
For that matter, if all of this is in the same machine, would you object to passing around handles in post messages directly to these other tasks? That's fast.
What do you mean? I think I'll try RPC for this but I'm just curious.
You just divided by zero, didn't you?
-
May 8th, 2009, 02:43 AM
#5
Re: How to hide/show running process.
 Originally Posted by _Superman_
If you mean show/hide the window that belongs to the process, you could try to send message to the main thread of the processes.
PostThreadMessage(pInfo->dwThreadId, WM_SHOWWINDOW, TRUE/FALSE, 0);
I just tried that and it didn't work.
But that's becuse this is console application that creates of it's own, so the threadId should be from newly created window. So I'm stuck with IPC.
You just divided by zero, didn't you?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|