Solved

How to execute calculative prognam for dos?

Posted on 1998-06-10
8
249 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
  • 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
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Header of docx file 17 118
max float value 3 51
How do i run a c++ file? 15 47
C++ Code Issue 4 26
What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

830 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