我有这个perl子例程在WinXP x86下正常工作,为32位应用程序排序列等等,但在Win7 x64下,这个子例程根本不起作用。其他工作正常(标签切换,按下按钮等)。知道为什么吗?
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 ,#nmh.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 );
}
}
答案 0 :(得分:1)
在32位和64位系统上,结构的打包方式不同。
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