Perl and LVN_COLUMNCLICK; works fine under WinXP x86, but not under Win7 x64. Why?
I have this perl subroutine that works fine under WinXP x86, sorting a column for a 32 bit application among other things, but under Win7 x64 this subroutine doesn't work at all. The others work fine(tabs switching, pressing buttons, etc). Any idea why?
sub function
{
my @searchresultswindow_handle = FindWindowLike( @_[ 0 ], undef, undef, $searchresultswindow_id );
if( !@searchresultswindow_handle )
{
die "Cannot find window handle for searchresultswindow control\n";
}
else
{
printf( "searchresultswindow handle is %x\n", $searchresultswindow_handle[ 0 ] );
$keysList=@searchresultswindow_handle[0] ;
my $action = pack( "l l",
0, #ptaction.x
0 #ptaction.y
);
my $action_ptr = unpack( 'L!', pack( 'P',$action));
my $str_buf = pack( "L L L l l L L L L l",
$keysList, #nmh.hdr.hwndFrom hwnd
0, #nmh.hdr.idFrom
4294967188, #LVN_COLUMNCLICK ,#开发者_如何学Gonmh.hdr.code Code
-1, #item
13, #sub item
0, #uNewState
0, #uOldState
0, #uChanged
$action_ptr, #action
0 #lparam
);
$lvitem = AllocateVirtualBuffer( $keysList, 5000 );
WriteToVirtualBuffer( $lvitem, $str_buf );
my $value =PostMessage( $keysList, 0x004E, 0, $lvitem->{ 'ptr' });
FreeVirtualBuffer( $lvitem );
}
}
The structures are packed differently on 32 and 64 bit systems.
on 32-bit:
0:000> dt tagNMHDR
notepad!tagNMHDR
+0x000 hwndFrom : Ptr32 HWND__
+0x004 idFrom : Uint4B
+0x008 code : Uint4B
on 64-bit:
0:000> dt tagNMHDR
kernel32!tagNMHDR
+0x000 hwndFrom : Ptr64 HWND__
+0x008 idFrom : Uint8B
+0x010 code : Uint4B
精彩评论