How to use job object
From: Ray (raywu0601_at_hotmail.com)
Date: 03/08/04
- Next message: HAri: "Re: AssociatedSystemBuffer Vs MdlAddress Vs UserBuffer"
- Previous message: Mathew Joy: "Re: Interpretting the symbols (WinDbg)"
- Next in thread: Gary Chanson: "Re: How to use job object"
- Reply: Gary Chanson: "Re: How to use job object"
- Messages sorted by: [ date ] [ thread ]
Date: Mon, 8 Mar 2004 20:18:15 +0800
Hi all,
I have a question about how to use job object.
In my project, I have to let user to execute other process,
I can't know which process will be executed in advance.
I want to compare the difference of registry before and after this process
executed.
So I want to know when this process terminate.
I know many processes will be ended after it spawns child processes.
So I tried to use job object to do this.
Here is my codes.
HANDLE hJob = CreateJobObject(NULL,"myJob");
STARTUPINFO si;
PROCESS_INFORMATION pi;
ZeroMemory( &si, sizeof(si) );
si.cb = sizeof(si);
ZeroMemory( &pi, sizeof(pi) );
if(CreateProcess( NULL, lpCommand, NULL, NULL, FALSE,
CREATE_SUSPENDED, NULL, NULL, &si, &pi ))
{
AssignProcessToJobObject(hJob, pi.hProcess);
ResumeThread(pi.hThread);
WaitForSingleObject(hJob, INFINITE);
CloseHandle( pi.hProcess );
CloseHandle( hJob );
}
But it can't work well.
It looks like the new process will not execute until my process is ended.
Is there any wrong in my codes?
My OS is Win2K.
Thanks!
- Next message: HAri: "Re: AssociatedSystemBuffer Vs MdlAddress Vs UserBuffer"
- Previous message: Mathew Joy: "Re: Interpretting the symbols (WinDbg)"
- Next in thread: Gary Chanson: "Re: How to use job object"
- Reply: Gary Chanson: "Re: How to use job object"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|