【问题标题】:How to access to SysListView32 Services Tab in Windows taskmanager如何在 Windows 任务管理器中访问 SysListView32 服务选项卡
【发布时间】:2013-12-20 10:05:54
【问题描述】:

我正在尝试从 Windows 任务管理器中恢复一些项目。 使用此代码,我从 Process 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 服务选项卡的句柄?

我正在使用的一些 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);
}

【问题讨论】:

  • 看起来像XY problem,如果你能说出你想要实现的目标,那将很容易提供帮助

标签: c# api winapi taskmanager


【解决方案1】:

您必须使用类名 (lpszClass) 等于“#32770”且窗口标题 (lpszWindow) 等于“服务”的 FindWindowEx。子 SysListView32 的 ID 则为 3504 (0x0000db0)。

这些数据来自 Spy++,用于法国 Windows Seven Pro 32 位操作系统。

【讨论】:

  • 这就是解决方案,使用正确的控制 ID(3504 而不是 1009)
猜你喜欢
  • 2019-07-30
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-12-21
  • 2010-11-13
相关资源
最近更新 更多