Closing CreateProcess() Window - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Closing CreateProcess() Window

Ed HallEd Hall Posts: 395Member
I'm working on a win32 application that opens a console program using CreateProcess(). I can close the console window later using TerminateProcess(), but it doesn't close until it wants to. I would lke to do an unconditional close, like when I click on the upper right close icon. The window also closes via a CTRL+C, but not by using SetFocus() and keybd_event(). I have also tried OpenProcess(DELETE, FALSE, processInfo.dwProcessId); which succeeded in acquiring a handle, but did not delete the process. I am unable to figure out if it is a security attribute problem or something else.

Thanks for any help.

Take Care,
Ed

Comments

  • AsmGuru62AsmGuru62 Posts: 6,519Member
    [color=Blue]So, can you post a code for CreateProcess()? What flags do you use? I run a console app - a FASM compiler and it closes as soon as FASM compiler terminates. Do you ran anything in that console or just open as standalone console?[/color]
  • Ed HallEd Hall Posts: 395Member
    The console program, in turn, uses other programs that it controls. It does not open any additional windows, but the only way to stop it when it is running, is by either closing the console window or using CTRL+C, which signals a save and close routine within the executable. TerminateProcess() will close the program (and console window, except when it is running some of the other programs. Unfortunately, the programs I need to cancel during, are ones that can run several days, depending on the numbers being worked with, so I can't really let it take its time after I call TerminateProcess().

    Here's my CreateProcess:
    [code]
    STARTUPINFO info={sizeof(info)};
    PROCESS_INFORMATION processInfo;
    ZeroMemory( &info, sizeof(info) );
    info.cb = sizeof(info);
    info.dwX = 0;
    info.dwY = 300;
    info.dwFlags = STARTF_USEPOSITION;
    CreateProcess(NULL, aliqueitCall, NULL, NULL, TRUE, 0, NULL, NULL, &info, &processInfo);
    [/code]
    Here's my TerminateProcess:
    [code]
    TerminateProcess(processInfo.hProcess, 0);
    [/code]
    Take Care,
    Ed
  • Ed HallEd Hall Posts: 395Member
    OK, I have a solution. I'm using FindWindow() to get a handle and then using PostMessage() with WM_CLOSE to terminate the process.

    Take Care,
    Ed
Sign In or Register to comment.