首页 新闻 会员 周边

远程获取目标进程信息

0
悬赏园豆:100 [已解决问题] 解决于 2012-04-13 07:45

需求如下:
客户端电脑:C1,C2,C3(OS:Windows2000,Windows2003);
服务器端Server(OS:Windows2003)。

C1、C2、C3上运行PP进程的不同版本,客户端PP进程的自动更新功能被人为关闭,PP进程会向Server上传数据。要求在Server上实现一个检测程序,来监控客户端PP程序,如果不是最新版本,则发送Close消息给客户端的PP进程。


大概思路:
1.获取客户端PP进程版本信息
2.与Server最新版本信息比对
3.发送Close消息给客户端PP进程


以下是MSDN上远程获取进程信息的参考代码,不知道还有无其他可行的方法来实现,请大家帮忙,谢谢

其中

VC中的Process^的用法看不懂,求解,谢谢

C#中函数执行报异常

Process [] ipByName = Process.GetProcessesByName("notepad", "169.0.0.0");

VC++
#using <System.dll> using namespace System;
using namespace System::Diagnostics;
using namespace System::ComponentModel;
int main()
{

   // Get the current process. Process^ currentProcess = Process::GetCurrentProcess();

   // Get all instances of Notepad running on the local
   // computer. array<Process^>^localByName = Process::GetProcessesByName( "notepad" );

   // Get all instances of Notepad running on the specific
   // computer.
   // 1. Using the computer alias (do not precede with "\\"). array<Process^>^remoteByName = Process::GetProcessesByName( "notepad", "myComputer" );

   // 2. Using an IP address to specify the machineName parameter.  array<Process^>^ipByName = Process::GetProcessesByName( "notepad", "169.0.0.0" );

   // Get all processes running on the local computer. array<Process^>^localAll = Process::GetProcesses();

   // Get all processes running on the remote computer. array<Process^>^remoteAll = Process::GetProcesses( "myComputer" );

   // Get a process on the local computer, using the process id. Process^ localById = Process::GetProcessById( 1234 );

   // Get a process on a remote computer, using the process id. Process^ remoteById = Process::GetProcessById( 2345, "myComputer" );
}
C#
using System;
using System.Diagnostics;
using System.ComponentModel;

namespace MyProcessSample
{
    /// <summary> /// Shell for the sample.
    /// </summary> class MyProcess
    {
        
       
        
        void BindToRunningProcesses()
        {
            // Get the current process. Process currentProcess = Process.GetCurrentProcess();

            
            // Get all instances of Notepad running on the local
            // computer. Process [] localByName = Process.GetProcessesByName("notepad");

            
            // Get all instances of Notepad running on the specifiec
            // computer.
            // 1. Using the computer alias (do not precede with "\\"). Process [] remoteByName = Process.GetProcessesByName("notepad", "myComputer");
            
            // 2. Using an IP address to specify the machineName parameter.  Process [] ipByName = Process.GetProcessesByName("notepad", "169.0.0.0");
            
            
            // Get all processes running on the local computer. Process [] localAll = Process.GetProcesses();

            
            // Get all processes running on the remote computer. Process [] remoteAll = Process.GetProcesses("myComputer");

            
            // Get a process on the local computer, using the process id. Process localById = Process.GetProcessById(1234);

            
            // Get a process on a remote computer, using the process id. Process remoteById = Process.GetProcessById(2345, "myComputer");
            
        }
        


        static void Main()
        {

                   MyProcess myProcess = new MyProcess();
            

            myProcess.BindToRunningProcesses();

            }    
    }
}
JK00的主页 JK00 | 初学一级 | 园豆:117
提问于:2012-04-11 17:02
< >
分享
最佳答案
1

远程获取进程信息不是难事,不过方式不是很可取,有点流氓软件的感觉。

上传数据的时候数据描述信息里携带自身版本信息就可以了,服务器进行一次验证。根据不同版本数据集特点进行处理,或者像你说的,发现不是最新版本发送close消息。

收获园豆:100
zsounder | 老鸟四级 |园豆:2819 | 2012-04-12 09:34

算不上流氓软件,在工厂端的工作环境。

上传的数据中并不包含程式自身的版本信息,主要是这点难办。因为旧版的程式有漏洞,客户端容易作弊,推行新版本又不能防止客户端继续使用旧版本。所以才有了在服务器端获取客户端进程版本信息的想法。

 

补充:客户端系统不包含.net框架,看C#的实现也是想找找思路,最好能用C++来实现。现在的客户端程式也是C++的。

JK00 | 园豆:117 (初学一级) | 2012-04-12 10:23

@Gala: 

如果一定需要着这样做,推荐你看一下远程读取注册表信息相关内容,网上很多,再有去看一下WMI

以后完全可以预留一个消息,当然要进行加密处理,服务器发出询问客户端版本请求,客户端给予回复。

zsounder | 园豆:2819 (老鸟四级) | 2012-04-13 02:33

@Wang Hui: 

是的,当初设计的时候考虑不全面。

谢谢您的建议

JK00 | 园豆:117 (初学一级) | 2012-04-13 07:44
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册