DllImport所在的名字空间 using System.Runtime.InteropServices;
[DllImport("User32.dll")]
public extern static System.IntPtr GetDC(System.IntPtr hWnd); private void button19_Click(object sender, EventArgs e) { System.IntPtr DesktopHandle= GetDC(System.IntPtr.Zero); Graphics g = Graphics.FromHdc(DesktopHandle); g.DrawRectangle(new Pen(Color.Red),new Rectangle(10,10,100,100)); } |
在屏幕上画图的C#实现代码
最新推荐文章于 2022-10-18 13:25:04 发布