.NET调用WINAPI 获取应用窗体句柄和内容

本文介绍如何在.NET环境中利用WINAPI函数获取应用程序的窗体句柄及窗体内容,涉及Windows API的调用技巧和相关知识点。
摘要由CSDN通过智能技术生成
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace cstest
{
    public partial class Form1 : Form
    { 
        //定义一个符合WINAPI返回值和参数的委托
        public delegate bool CallBack(IntPtr hwnd, int lParam);
        //声明符合上述委托的函数(定义一个函数指针)
        private static CallBack myCallBack;
        public Form1()
        {
            myCallBack = new CallBack(Report);
        InitializeComponent();
            GetHandle("C#");
            this.textBox1.Multiline = true;
            this.textBox1.Dock = DockStyle.Fill;
        }

        private void GetHandle(string windcaption)
        {
            IntPtr mainHandle = FindWindow(null, windcaption);
            if (IntPtr.Zero != mainHandle)
          
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值