Solved

Close DOS application command

Posted on 2000-03-18
8
378 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Errors will happen. It is a fact of life for the programmer. How and when errors are detected have a great impact on quality and cost of a product. It is better to detect errors at compile time, when possible and practical. Errors that make their wa…
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…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

863 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

24 Experts available now in Live!

Get 1:1 Help Now