elysia,
you mentioned to use getwindow, getnextwindow api, i guess
what about it?
Printable View
That use of terminate process was an example to Terminate the process with only its identifier.
ExitProcess is another api function that is similar to TermimateProcess but I don't think that is waht you are looking for. If you want to tell notepad to close and then give notepad the option of doing something first (getting user input), the only way I can think of is to use its handle in a call to SendMessage and send the process a WM_CLOSE message. As the handle should be one to its main window (definitely not a child window) it should be the same as the user clicking on the X button or going File>Exit in notepad. I haven't done this before so I am not sure of it, but it should work in theory. Try it, I would like to see if it works
//added:
I think Elysia is referring to look at EnumChildWindows which from msdn: "The EnumChildWindows function is more reliable than calling GetWindow in a loop. An application that calls GetWindow to perform this task risks being caught in an infinite loop or referencing a handle to a window that has been destroyed."