?
Solved

How to execute calculative prognam for dos?

Posted on 1998-06-10
8
Medium Priority
?
266 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 400 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
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

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

New benefit for Premium Members - Upgrade now!

Ready to get started with anonymous questions today? It's easy! Learn more.

Question has a verified solution.

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

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…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
Suggested Courses

764 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