Solved

Close DOS application command

Posted on 2000-03-18
8
377 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
 
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
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 

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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
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 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 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…

760 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now