我正在尝试从Windows taskmanager恢复一些项目。
通过此代码,我从进程TAB中恢复了SysListView32句柄:
(dlgItem)
IntPtr mainWindowHandle = Process.GetProcessesByName("taskmgr")[0].MainWindowHandle;
Api.WindowPlacement lpwndpl = new Api.WindowPlacement();
lpwndpl.length = Marshal.SizeOf((object) lpwndpl);
Api.GetWindowPlacement(mainWindowHandle, ref lpwndpl);
bool flag1 = lpwndpl.showCmd == 1 || lpwndpl.showCmd == 3;
IntPtr dlgItem = Api.GetDlgItem(Api.FindWindowEx(mainWindowHandle, IntPtr.Zero, (string) null, (string) null), 1009);
如何恢复SysListView32 Services TAB的句柄?
我使用以下一些API定义:
internal static class Api
{
public struct Rect
{
private int left;
private int top;
private int right;
private int bottom;
}
public struct Point
{
private int x;
private int y;
}
public struct WindowPlacement
{
public int length;
public int flags;
public int showCmd;
public Api.Point ptMinPosition;
public Api.Point ptMaxPosition;
public Api.Rect rcNormalPosition;
}
[DllImport("user32.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool GetWindowPlacement(IntPtr hWnd, ref Api.WindowPlacement lpwndpl);
[DllImport("user32.dll")]
public static extern IntPtr GetDlgItem(IntPtr hDlg, int nIDDlgItem);
[DllImport("user32.dll", SetLastError = true)]
public static extern IntPtr FindWindowEx(IntPtr hwndParent, IntPtr hwndChildAfter, string lpszClass, string lpszWindow);
}
最佳答案
您必须使用FindWindowEx
,其类名(lpszClass
)等于“#32770”,并且窗口标题(lpszWindow
)等于“ Services”。子SysListView32的ID为3504(0x0000db0)。
这些数据来自在法国Windows Seven Pro 32位操作系统上使用的Spy ++。
关于c# - 如何在Windows taskmanager中访问SysListView32服务选项卡,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/20701052/