Solved

Close DOS application command

Posted on 2000-03-18
8
383 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
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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.

 
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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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

Title # Comments Views Activity
Writing a parser for java language 4 83
c++ getting the first 10 characters of a char* string 11 98
Dynamically allocate memory 9 62
sorting efficency of sorting algorithm 30 121
Often, when implementing a feature, you won't know how certain events should be handled at the point where they occur and you'd rather defer to the user of your function or class. For example, a XML parser will extract a tag from the source code, wh…
C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

808 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