如题~注意是应用程序标题名称,非进程名求代码~
解决方案 »
- 怎么连接数据库?
- VS2008快捷键
- C#能编写动态链接库供Sql Server 2000存储过程调用吗?
- vs.net WinForm FormBorderStyle设为None后,无法做出高度小于27px的窗体,高人救命!在线等
- PlatformNotSupportedException错误,请高手帮帮我。
- 这个怎么用?
- 请教,在C#中如何确定连接设备是什么类型?枚举不到开发板设备怎么办?
- 一个控制台程序。
- c#在web应用中,在使用web forms 的时候, ie无法显示窗体控件,为什么??
- [求助]C#自定义类型时,如何让返回值为NULL
- 报“线程间操作无效: 从不是创建控件的线程访问它”用代理不行
- DataList跟GridView区别在哪里?
private extern static int GetWindow(int hWnd, int wCmd); [DllImport("User32")]
private extern static int GetWindowLongA(int hWnd, int wIndx); [DllImport("user32", CharSet = CharSet.Auto)]
private extern static int GetWindowTextLength(IntPtr hWnd); [DllImport("user32.dll")]
private static extern bool GetWindowText(int hWnd, StringBuilder title, int maxBufSize); private const int GW_HWNDFIRST = 0;
private const int GW_HWNDNEXT = 2;
private const int GWL_STYLE = (-16);
private const int WS_VISIBLE = 268435456;
private const int WS_BORDER = 8388608; public List <string> GetRunApplicationList(Form appForm)
{
try
{
List <string> appString = new List <string>();
int handle = (int)appForm.Handle;
int hwCurr;
hwCurr = GetWindow(handle, GW_HWNDFIRST);
while (hwCurr > 0)
{
int isTask = (WS_VISIBLE | WS_BORDER);
int lngStyle = GetWindowLongA(hwCurr, GWL_STYLE);
bool taskWindow = ((lngStyle & isTask) == isTask);
if (taskWindow)
{
int length = GetWindowTextLength(new IntPtr(hwCurr));
StringBuilder sb = new StringBuilder(2 * length + 1);
GetWindowText(hwCurr, sb, sb.Capacity);
string strTitle = sb.ToString();
if (!string.IsNullOrEmpty(strTitle))
{
appString.Add(strTitle);
}
}
hwCurr = GetWindow(hwCurr, GW_HWNDNEXT);
}
return appString;
}
catch (Exception ex)
{
throw new ApplicationInfoException("读取应用程序信息时出错:" + ex.Message);
}
}
我做过一个简单的任务管理器,能得到应用程序名的