class1.cs
来自「150个经典的入门学习程序源代码」· CS 代码 · 共 35 行
CS
35 行
using System;
using System.Runtime.InteropServices;
namespace Example077_实现回调函数
{
/// <summary>
/// Class1 的摘要说明。
/// </summary>
public delegate bool CallBack(int hwnd, int lParam);
class Class1
{
/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
[DllImport("user32")]
public static extern int EnumWindows(CallBack x, int y);
static void Main(string[] args)
{
//
// TODO: 在此处添加代码以启动应用程序
//
CallBack myCallBack = new CallBack(Class1.Report);
EnumWindows(myCallBack, 0);
Console.Read();
}
public static bool Report(int hwnd, int lParam)
{
Console.Write("Window handle is ");
Console.WriteLine(hwnd);
return true;
}
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?