Help with a job? -in windows

I have been trying to figure out jobs and processes the past couple of days, and I got processes down (<- pretty much), as for jobs, I am still having trouble.

So, to the point. I am made a quick little program that uses a job to call two processes that open MS Paint and Notepad. Well, I am stuck, and I don't exactly know if I am doing this right...

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#include <iostream>
#include <windows.h>
using namespace std;

int main(){
    TCHAR notePad[] = TEXT("notepad.exe");
    TCHAR openPaint[] = TEXT("mspaint.exe");
    PROCESS_INFORMATION pi;
        ZeroMemory(&pi, sizeof(pi));

    STARTUPINFO si;
        ZeroMemory(&si, sizeof(si));
        si.cb = sizeof(si);
    HANDLE jObject = CreateJobObject(NULL, L"Job");
    HANDLE hProcess1 = OpenProcess(NULL, FALSE, PROCESS_ALL_ACCESS);
    HANDLE hProcess2 = OpenProcess(NULL, FALSE, PROCESS_ALL_ACCESS);
    AssignProcessToJobObject(jObject, hProcess1);
    AssignProcessToJobObject(jObject, hProcess2);
}


Well, I don't know what to do next. I don't want to use CreateProcess because I don't think that is what you do for jobs, and you let the jobs do the work. Anyway, can I have some help?
The purpose of jobs is to group related processes(and optionally place restrictions on them), since Windows doesn't maintain parent-child relationships between processes. E.g., if you terminate a process then any "child" processes that it spawned will continue to execute. If you wanted to terminate an entire hierarchy of processes then you'd probably want to first group them into a job.

This is my understanding of jobs. I can say with some certainty though, that there is no good reason to group notepad and mspaint together.
I can say with some certainty though, that there is no good reason to group notepad and mspaint together.

I know I am just testing out code to see if I understand it.

As for the answer, that did help me. So, thanks.
Topic archived. No new replies allowed.