Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Visual C++ problem. Easy!

Posted on 2003-02-22
12
Medium Priority
?
763 Views
Last Modified: 2012-06-27
Visual C++ problem!!!

I have a problem with a Borland C++ Dos converter i've made. Here's the part you need of the code:

void CBorlandCConverterDlg::OnStart()
{
     
     WinExec("bcc32 " + m_Target, SW_SHOW);
     
}
          After this DOS command I want a pause, so the command window will be there until the person pushes a button.

So the program works fine, but When this command is finished the command window closes itself.

Thanks!
0
Comment
Question by:TMM
11 Comments
 

Expert Comment

by:Fallen_Knight
ID: 7998646
well if you want a delay untill user action:

use iostream and just go

char ch;

cout << "Press any key to continue"
cin >> ch;

or even just a cin.get(); might work just fine.

so
void CBorlandCConverterDlg::OnStart() {
    WinExec("bcc32 " + m_Target, SW_SHOW);
    cin.get();
}
0
 

Author Comment

by:TMM
ID: 7999119
This is a Windows program, not a DOS...
0
 
LVL 3

Expert Comment

by:EarthQuaker
ID: 7999234
system("pause");
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 22

Accepted Solution

by:
nietod earned 80 total points
ID: 7999437
rather than running the bcc32 program directly, run a command interpreter (command.com or cmd32.exe depending on the OS) and have the command interpreter run bcc32.
0
 
LVL 22

Expert Comment

by:nietod
ID: 7999450
For example

  WinExec("command.com /Kbcc32 " + m_Target, SW_SHOW);

this runs command.com with the /K command-line option, which runs a command and then after the command finishes, command.com continues to operate--wait for user input.

>> system("pause");
that douesn't work.  TMM needs to pause in an exusting  DOS box after it has completed a task.
0
 
LVL 22

Expert Comment

by:nietod
ID: 7999488
I should mention that you can get the path to and name of the command interpretter using the COMSPEC environmental variable
0
 

Author Comment

by:TMM
ID: 8078485
Thanks nietod, but it dosen't work.
Do you have another method???
0
 
LVL 22

Expert Comment

by:nietod
ID: 8079158
I what way doesn't it work?  (doesn't run, doesn't run right, doesn't pause ....)    Don't abandon the approach at the first setback.  It will work.
0
 

Author Comment

by:TMM
ID: 8097465
The command window says "invaild reference!"
Do you know whats wrong then?
Thanks
0
 
LVL 22

Expert Comment

by:nietod
ID: 8102619
post your code.   I need to see what you are doing
0
 
LVL 11

Expert Comment

by:bcladd
ID: 9784174
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

Answered: Points to nietod

Please leave any comments here within the next seven days. Experts: Silence
means you don't care.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

-bcl (bcladd)
EE Cleanup Volunteer

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

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…
Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
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 be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

575 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