邪风戏雨

青斗笠,绿蓑衣,斜风细雨不须归。

导航

捕捉桌面活动窗体的标题及其进程。

Posted on 2004-11-30 18:33  fdreg  阅读(1567)  评论(2)    收藏  举报

 一段捕捉桌面活动窗体的标题及其进程的代码。主要利用了API及Process类。

using System;
using System.Runtime.InteropServices;
using System.Text;
using System.Runtime.CompilerServices;
using System.Diagnostics;
using System.Reflection;

public class GetActiveWin
    
{
        
Win32 API

        
全局变量

        
方法

        
    }


可以用来:1、利用API  GetForegroundWindow 获得句柄,捕捉当前活动窗体的名字;
                 2、并根据活动窗体的句柄, 得到该窗体的使用进程;
                 3、根据进程,利用System..Diagnostics.Process,得到进程名,及其路径。