Solved

getting rid of DOS console window

Posted on 2002-03-15
3
384 Views
Last Modified: 2008-02-01
I start a process using CreateProcess as follows, which starts with a minimized DOS console window which, in turn, starts a GUI. I want the console window closed automatically when the GUI is closed. I tried the following code. It doesn't work.
----------------------------------
CreateProcess(NULL,"cmd.exe /c start /min test.bat",NULL,NULL,FALSE,NORMAL_PRIORITY_CLASS,NULL,NULL,&StartInfo,&pInfo);
HANDLE hp=pInfo.hProcess;
LPDWORD pExitCode=NULL;
GetExitCodeProcess(hp, pExitCode);
ExitProcess(*pExitCode);
----------------------------------
0
Comment
Question by:j4months
3 Comments
 
LVL 86

Expert Comment

by:jkr
ID: 6869245
What is your "STARTUP_INFO" struct like?

It should be

 STARTUPINFO siStartInfo;

    // Set up the start up info struct.
    ZeroMemory(&siStartInfo,sizeof(STARTUPINFO));
    siStartInfo.cb = sizeof(STARTUPINFO);
    siStartInfo.dwFlags = STARTF_USESHOWWINDOW;
    siStartInfo.wShowWindow = SW_HIDE;
0
 

Author Comment

by:j4months
ID: 6869433
I modified the STARTUPINFO as you described, it didn't make a difference..
actually my problem is not at the startup. it's when I close the GUI window..
0
 
LVL 1

Accepted Solution

by:
allym earned 50 total points
ID: 6869563
What's in the batch file? Try putting "exit" as the last command.

0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question