perl-win32-gui  

[perl-win32-gui] Help -- PostMessage() or SendMessage()

A. C. Yardley
Mon, 04 Dec 2000 12:03:41 -0800

Hello,

I need a bit of help here:  I'm try to use the Win32::API module to
call WinAPI's PostMessage() or SendMessage() functions.  Please see below.

use constant;
use Win32:API;
..
..
..
use constant NULL => 0;
use constant WM_COPYDATA => 74;
use constant WM_USERKILL => 99999;
..
..
..

So, would a call to PostMessage() look like

my $PostMessage = new Win32::API "user32", "PostMessage", [qw(N N P P)], 'N';

or

my $PostMessage = new Win32::API "user32", "PostMessage", [qw(N N N
N)], 'N';


Then, how do I properly pack the COPYDATASTRUCT and then get a
pointer to the packed structure in order to pass it as a parameter
in the PostMessage() call?  Does the below bit of code appear
correct?  (Because it doesn't work.)

my $wparm = pack("I", NULL);
my $lpCopydatastruct = pack("III", WM_USERKILL, 4, NULL);
my $lparm = pack("P", $lpCopydatastruct);
my $lresult = $PostMessage->Call($hwnd, WM_COPYDATA, $wparm, $lparm);

Thanks in advance.

ACY
  • [perl-win32-gui] Help -- PostMessage() or SendMessage() A. C. Yardley