How does PHP call other language programs?

Source: Internet
Author: User
PHP calls other language programs. PHP provides two functions: 1 system () 2. by calling exec, we can implement many functions that PHP cannot implement. here I use C ++ to test how to use PHP to call the C ++ EXE program to obtain the process of the current system. !. (Source: Mobile app Mall (cmccapp.com) how PHP calls programs in other languages

PHP provides two functions: 1 system () 2. by calling exec, we can implement many functions that PHP cannot implement. here I use C ++ to test how to use PHP to call the C ++ EXE program to obtain the process of the current system. !. (Source: Mobile app Mall (cmccapp.com ))

1. VC creates the W32 console program CODE:

# Include
# Include "windows. h"
# Include "tlhelp32.h"
# Include "stdio. h"
Using namespace std;
Int main (int argc, char * argv [])
{
??? PROCESSENTRY32 pe32;
??? Pe32.dwSize = sizeof (pe32 );
??? HANDLE hProcessSnap =: createconlhelp32snapshot (TH32CS_SNAPPROCESS, 0 );
??? If (hProcessSnap = INVALID_HANDLE_VALUE)
??? {
??? ??? Cout <"failed to get process! \ N ";
??? ??? Return-1;
??? }
??? BOOL bMore =: Process32First (hProcessSnap, & pe32 );
??? While (bMore)
??? {
??? ??? Printf ("process name: % s \ n", pe32.szExeFile );
??? ??? Printf ("process ID % u \ n
", Pe32.th32ProcessID );
??? ??? BMore =: Process32Next (hProcessSnap, & pe32 );
??? }
??? : CloseHandle (hProcessSnap );
??? Return 0;
}

Compile it into EXE!

Then write the CODE in PHP:

System ("D :\\ APMServ5.2.6 \ www \ wotu \ test.exe 20", $ info );
Print_r ($ info );
?>

Change the path to your path and try it out!

This article is from mobile app Mall (cmccapp.com )? Please repost the famous source!

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.