使用API的EnumWindows方法枚舉當前所有的HANDLE

using System;
using System.Runtime.InteropServices;

public class CSharpAPIsDemo
 {  
  public CSharpAPIsDemo()
  {
  }

  [DllImport("user32")]
  public static extern int EnumWindows(CallBack x, int y);
  public delegate bool CallBack(int hwnd, int lParam);
  public static bool Report(int hwnd, int lParam)
  {
   Console.Write("Window handle is :");
   Console.WriteLine(hwnd);
   return true;
  }
  public void PrintHandles()
  {
   CallBack myCallBack = new CallBack(Report);
   EnumWindows(myCallBack, 0);
  }
 }

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章