Solved

Close DOS application command

Posted on 2000-03-18
8
381 Views
Last Modified: 2010-04-10
May I know is there any C or C++ command that will close the C++ application? To close means close the window entirely. If there isn't any C or C++ command then is there any DOS command that will close a window? Example "start" command will open an application but I want a close window command.

hongjun
0
Comment
Question by:hongjun
8 Comments
 
LVL 14

Expert Comment

by:AlexVirochovsky
ID: 2632563
  HOWTO: Terminate an Application "Cleanly" in Win32
http://support.microsoft.com/support/kb/articles/Q178/8/93.ASP


0
 
LVL 33

Author Comment

by:hongjun
ID: 2632610
AlexVirochovsky,
I think I cannot understand the entire source code given in the webpage you gave me.

hongjun
0
 
LVL 14

Expert Comment

by:AlexVirochovsky
ID: 2633347
Hi. Next is small explanation of example from article.
1. Must enumerate all processes in Memory
   For this must use Process32First/Process32Next Api
2. Find you Apps(by name)
3. Close it (sending WM_CLOSE)
A bit other (but good too) way see in
http://www.codeguru.com/win32/ps.shtml
0
Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

 
LVL 86

Expert Comment

by:jkr
ID: 2634220
>>May I know is there any C or C++
>>command that will close the C++
>>application?

This is OS specific, not language specific...

Do you just want to hide the window or to exit/terminate the application? Are you talking about a 'real' DOS app or a Win32 console application? Are you using NT or Win9x?
0
 

Expert Comment

by:JeffP
ID: 2634463
Not sure what you are trying to do here, but if you are trying to simply close the console-window for the application you are running, there is a way to terminate your console without terminating your application.  If this is what you are after, let me know and I will comment more fully.

JeffP
0
 
LVL 33

Author Comment

by:hongjun
ID: 2636143
I have downloaded the example source code from the codeguru site but it cannot work.
I am using VC++ 6.0.

hongjun
0
 
LVL 14

Accepted Solution

by:
AlexVirochovsky earned 50 total points
ID: 2636481
What name you use for kill apps?
For dos there is special name:
"WINOA386.MOD". Testx must be as:

if (strstr(proc.szExeFile, "WINOA386.MOD"))
          {
           // close dos process
//by kill/or sendmessang WM_CLOSE
          }

    while (Process32Next(snapshot, &proc) == TRUE)
      {
        strupr(proc.szExeFile);
        if (strstr(proc.szExeFile, "WINOA386.MOD"))
          {
             //dos process
          }
      }
/*
0
 
LVL 33

Author Comment

by:hongjun
ID: 2638776
I don't think I am able to understand a single thing. But thanks for all your help especially AlexVirochovsky.

Thanks
hongjun
0

Featured Post

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
how not to pass environment to child process by using ShellExecute or ShellExecuteEx 16 115
c++ syntax question 9 49
Beginner to Unreal Engine 4 5 80
max float value 3 41
What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
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 user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

810 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