Solved

How to execute calculative prognam for dos?

Posted on 1998-06-10
8
226 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
 
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
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

758 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

21 Experts available now in Live!

Get 1:1 Help Now