VC Invoke External Program interface

Source: Internet
Author: User

(1) system ()

Function Name: System

Function: Issue a DOS command

Usage: int system (char *command);

Note: The system function has been included in the standard C library and can be directly invoked

return value

=-1: Error occurred

= 0: The call succeeded but no child processes appear

>0: ID of the child process that successfully exited

Sample:

System ("D:\\game.exe");
System ("Mmc.exe \" "C:\\windows\\system32\\gpedit.msc\");

(2) WinExec ()

Function Prototypes:

UINT WINAPI WinExec (

__in LPCSTR lpCmdLine,

__in UINT ucmdshow);

Parameter description:

lpCmdLine,//command path

Ucmdshow,//display mode, there are 11 kinds, you can check the MSDN ShowWindow function

return value:

Success, the return value is greater than 31

Returns 0 indicating a memory or resource overflow

Return Error_bad_format indicates that the EXE file is illegal or corrupted.

Returned error_file_not_found the specified file was not found.

Return Error_path_not_found cannot find the specified path

Sample Example:

WinExec ("Notepad.exe", sw_show); Open Notepad

WinExec ("D:\\Program files\\test\\test.exe", sw_showmaximized); Open Test.exe in a maximized manner (note that the file name must be the same case)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.