windows消息队列C语言,通过Windows消息队列对VB程序进行操作

这篇博客展示了如何运用Java Native Access (JNA) 库来操作DLL函数,获取VB窗口程序的句柄,并向VB程序的消息队列发送消息。通过示例代码,演示了GetForegroundWindow、FindWindowEx、SendMessage等函数的使用,实现与VB程序的交互。
AI助手已提取文章相关产品:

运用JNA来操作DLL函数,获取VB窗口程序句柄,进而向VB程序窗口程序的消息队列发送消息,代码如下:

package com.stupidzhe;

import com.sun.jna.Native;

import com.sun.jna.platform.win32.User32;

import com.sun.jna.platform.win32.WinDef;

import com.sun.jna.platform.win32.WinDef.HWND;

import com.sun.jna.platform.win32.WinUser;

import java.util.concurrent.TimeUnit;

public class JnaTest {

public static void main(String[] args) throws InterruptedException {

char[] windowText = new char[512];

HWND hwnd = User32.INSTANCE.GetForegroundWindow(); // then you can call it!

User32.INSTANCE.GetWindowText(hwnd, windowText, 512);

System.out.println(Native.toString(windowText));

HWND btn = User32.INSTANCE.FindWindowEx(hwnd, null, null, null);

WinUser.MSG msg = new WinUser.MSG();

int result;

while (true) {

WinDef.LRESULT res = User32.INSTANCE.SendMessage(btn, 0xF5, new WinDef.WPARAM(0), new WinDef.LPARAM(0));

User32.INSTANCE.GetWindowText(btn, windowText, 512);

System.out.println(Native.toString(windowText));

TimeUnit.SECONDS.sleep(2);

}

}

}

您可能感兴趣的与本文相关内容

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符  | 博主筛选后可见
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值