Solved

How to execute calculative prognam for dos?

Posted on 1998-06-10
8
258 Views
Last Modified: 2010-04-01
Dear Sir:

    Three months ago,I wrote three prognams with
TC,suppose their names:a.exe,b.exe,c.exe;now,
I desire  write a menu in vc5 so that I can contract
the three prognams,but, when I use the function "system()",It don't display any result. I think You can help me to solve this difficulty.Thank You!
ps:at best,use a SDI prognam.
                             Youngest
0
Comment
Question by:youngest
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
  • 2
8 Comments
 
LVL 23

Accepted Solution

by:
chensu earned 200 total points
ID: 1165632
Use CreateProcess, WinExec or ShellExecute to execute them.
0
 

Author Comment

by:youngest
ID: 1165633
Can you explain clearly?

       Thank You!
0
 
LVL 23

Expert Comment

by:chensu
ID: 1165634
Instead of using system("a.exe"), use for example

1.
STARTUPINFO StartupInfo =
{
    sizeof(STARTUPINFO),
    NULL,
    NULL,
    NULL,
    0, 0,
    0, 0,
    0, 0,
    0,
    STARTF_USESHOWWINDOW,
    SW_SHOW,
    0,
    NULL,
    NULL,
    NULL,
    NULL
};

PROCESS_INFORMATION ProcessInformation;

if (!::CreateProcess(NULL,
                     _T("a.exe"),
                     NULL,
                     NULL,
                     TRUE,
                     0,
                     NULL,
                     NULL,
                     &StartupInfo,
                     &ProcessInformation))
{
    LPVOID lpMsgBuf;
    ::FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER |
                    FORMAT_MESSAGE_FROM_SYSTEM,
                    NULL,
                    ::GetLastError(),
                    MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
                    (LPTSTR)&lpMsgBuf,
                    0,
                    NULL);
   
    // Display the string.
    ::AfxMessageBox((LPCTSTR)lpMsgBuf);
   
    // Free the buffer.
    ::LocalFree(lpMsgBuf);
}

2. ::WinExec("a.exe", SW_SHOW);

3. ::ShellExecute(hWnd, NULL, _T("a.exe"), NULL, NULL, SW_SHOWNORMAL);
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 22

Expert Comment

by:nietod
ID: 1165635
Note that this program you are creating in VC will have to be a windows program.  VC5 does not create DOS programs.  (you can create a windows console program, which is in many ways similar to a DOS program.)
0
 
LVL 23

Expert Comment

by:chensu
ID: 1165636
nietod,

youngest told us "Three months ago,I wrote three prognams with
TC". By TC, he meant Turbo C, I guess. He is using Visual C++ to write a Windows program which executes those DOS programs.
0
 
LVL 22

Expert Comment

by:nietod
ID: 1165637
yeah, I realized that the DOS programs were written in turbo debugger.   But I was wondering if he might also want this progran to be a DOS program, since (1) the others are and (2) I recall him asking questions about windows programs before.   Probably not, but I just thought it might be helpful.  (I have seen questions like.  I just spent $$ on VC and can't get it to compie my DOS program....)
0
 

Author Comment

by:youngest
ID: 1165638
Thank  You for help,despite I can't understand it.
Because I just learn VC++.I plan to write a pop-up
menu,I can choose the item to execute my prognam,
at best,I desire display the results  in SDI,and can print
it .
0
 
LVL 23

Expert Comment

by:chensu
ID: 1165639
You can use the code I provided directly. Just change the program file name (a.exe).
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Embarcadero WebBroker REST server endpoint parameters 2 114
Why isn't object file created? 6 105
Where are the c++ header files to use in Eclipse? 4 72
C++ Code Issue 4 47
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…
Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
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.

739 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