从同一台PC上的应用程序捕获消息 [英] Catching message from app in same PC

查看:71
本文介绍了从同一台PC上的应用程序捕获消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我需要捕获同一台PC上另一个应用程序发出的消息.
我使用的是VB6.0,请给我一些示例.
以下是其他应用程序的源代码.

Hi,
I need to catching the messaged from another application in same PC.
I use VB6.0 ,please kindly advise some sample to me.
below is the source code from other app.

   // To open job:
IntPtr open_autocompiler = FindWindow("TSSLA", "SSLA");
if (open_autocompiler == IntPtr.Zero)
{
MessageBox.Show("This window cannot open");
return;
}
else
{
SetForegroundWindow(open_autocompiler); //set AutoCompiler to main window
WM_USER+100.wparam("1"); //hint: wparam data is (WORD) type.
}

   // To cancel job:
IntPtr open_autocompiler = FindWindow("TSSLA", "SSLA");
if (open_autocompiler == IntPtr.Zero)
{
MessageBox.Show("This window cannot open");
return;
}
else
{
SetForegroundWindow(open_autocompiler); //set AutoCompiler to main window
WM_USER+100.wparam("2"); //hint: wparam data is (WORD) type.
}


谢谢,

我的电子邮件:[已删除电子邮件]


Thanks,
Rod
my email: [Email Removed]

推荐答案

而且其中的一部分几乎不可能在VB6中实现(可能只是不可能).这部分要求编写DLL应该用C ++编写.还有其他选项,例如Object Pascal(Delphi)或任何其他可以与原始Windows代码一起使用并创建DLL的成熟编译器. VB6不是一个真正的"编译器,因此这不是一个选择.

通过安装 Windows挂钩,可以捕获消息.您可以从这里开始:
http://msdn.microsoft.com/en-us/library/ms632589 (v = vs.85).aspx [http://msdn.microsoft.com/en-us/library/ms644990(v=vs.85).aspx [
This is not easy at all; and there is a part of it which is nearly impossible to achieve in VB6 (probably just impossible). This part requires writing a DLL should be written in C++. There are other options like Object Pascal (Delphi) or any other fully-fledged compiler which can work with raw Windows code and create DLLs. VB6 is not a "real" compiler, so this is not an option.

Capturing message is possible through installing Windows Hooks. You can start from here:
http://msdn.microsoft.com/en-us/library/ms632589(v=vs.85).aspx[^].

Now, according to Microsoft documentation on hooks, capturing messages dispatched to windows of other process requires installation of the hook through the function SetWindowsHookEx (see http://msdn.microsoft.com/en-us/library/ms644990(v=vs.85).aspx[^]) in a DLL. This is where VB6 limitations come into play.

My best advice would be: don''t even try it, unless you have pretty serious software development experience on the level of raw Windows API and plenty of perseverance.

—SA


这篇关于从同一台PC上的应用程序捕获消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆