C/C++ Windows API

Moderators: Lundin
Number of threads: 443
Number of posts: 1215

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
Closing CreateProcess() Window Posted by Ed Hall on 16 Apr 2010 at 9:24 AM
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
Report
Re: Closing CreateProcess() Window Posted by AsmGuru62 on 16 Apr 2010 at 5:59 PM
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?
Report
Re: Closing CreateProcess() Window Posted by Ed Hall on 16 Apr 2010 at 6:41 PM
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:
     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);

Here's my TerminateProcess:
        TerminateProcess(processInfo.hProcess, 0);

Take Care,
Ed
Report
Re: Closing CreateProcess() Window - Solved Posted by Ed Hall on 17 Apr 2010 at 11:35 AM
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



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.