Click here to Skip to main content
16,015,641 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
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.

VB
   // 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]
Posted
Updated 10-Jun-11 19:56pm
v2

1 solution

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
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900