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!