今天无聊想了下PHP能想C++那样做点低层的东西就牛B了 虽然这要求十分苛刻 比较方向不是一样 不过PHP要能在这方面加强点也不错啊 突发其想 PHP要获得当前用户进程怎么办? 立马想到的是exec执行CMd命令 这不是我想要的效果 我想通过C++怎样来实现 结果乱搞被搞出来了分享下 呵呵
VC建立W32控制台程序 CODE如下:
#include<iostream>
#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 = ::CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS,0);
if(hProcessSnap==INVALID_HANDLE_VALUE)
{
cout<<"获取进程失败!\n";
return -1;
}
BOOL bMore = ::Process32First(hProcessSnap,&pe32);
while(bMore)
{
printf("进程名称: %s\n",pe32.szExeFile);
printf("进程ID %u\n\n<br>",pe32.th32ProcessID);
bMore = ::Process32Next(hProcessSnap,&pe32);
}
::CloseHandle(hProcessSnap);
return 0;
}编译生成EXE放在PHP 目录 PHP代码如下 :
<?php
system("D:\\APMServ5.2.6\\www\\wotu\\test.exe 20", $info);
print_r($info);
?>
来张贴图吧
VC建立W32控制台程序 CODE如下:
#include<iostream>
#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 = ::CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS,0);
if(hProcessSnap==INVALID_HANDLE_VALUE)
{
cout<<"获取进程失败!\n";
return -1;
}
BOOL bMore = ::Process32First(hProcessSnap,&pe32);
while(bMore)
{
printf("进程名称: %s\n",pe32.szExeFile);
printf("进程ID %u\n\n<br>",pe32.th32ProcessID);
bMore = ::Process32Next(hProcessSnap,&pe32);
}
::CloseHandle(hProcessSnap);
return 0;
}编译生成EXE放在PHP 目录 PHP代码如下 :
<?php
system("D:\\APMServ5.2.6\\www\\wotu\\test.exe 20", $info);
print_r($info);
?>
来张贴图吧
#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 = ::CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS,0);
if(hProcessSnap==INVALID_HANDLE_VALUE)
{
cout<<"获取进程失败!\n";
return -1;
}
BOOL bMore = ::Process32First(hProcessSnap,&pe32);
while(bMore)
{
printf("进程名称: %s\n",pe32.szExeFile);
printf("进程ID %u\n\n<br>",pe32.th32ProcessID);
bMore = ::Process32Next(hProcessSnap,&pe32);
}
--------------这段代码是c++?
要在系统环境中设置php.exe的路径。呵呵。写网络程序客户端为了简单,曾经用PHP写过一个服务器端,打开一端口进行监听。
php只是一到桥,也没必要太依赖apache,至于超时,可以通过几它方法解决,
用php触发程序,断开连接,程序自己成完后,再通知或调用php处理结果。
楼主好样的,加油,学习了
难道你认为那是B++? OR G++
用系统的定时任务 crontab