2011-01-28 47 views
2

我有這個perl子例程,在WinXP x86下工作正常,在32位應用程序中對列進行排序,但在Win7 x64下,此子例程完全不起作用。其他工作正常(標籤切換,按下按鈕等)。任何想法爲什麼?Perl和LVN_COLUMNCLICK;在WinXP x86下工作正常,但不在Win7 x64下工作。爲什麼?

sub function  
{ 
my @searchresultswindow_handle = FindWindowLike(@_[ 0 ], undef, undef, $searchresultswindow_id); 
if([email protected]_handle ) 
    { 
    die "Cannot find window handle for searchresultswindow control\n"; 
    } 
else 
    { 
    printf("searchresultswindow handle is %x\n", $searchresultswindow_handle[ 0 ]); 

      [email protected]_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); 
} 
} 
+1

你能更具體的不是 「沒有在所有的工作」?會發生什麼,你會得到什麼錯誤? – Ether 2011-01-28 22:05:55

+1

是的,給我們一個骨頭,告訴我們什麼模塊`FindWindowLike`和`AllocateVirtualBuffer`來自。 – mob 2011-01-29 00:05:31

回答

1

結構在32位和64位系統上的打包方式不同。

32位:

0:000> dt tagNMHDR 
notepad!tagNMHDR 
    +0x000 hwndFrom   : Ptr32 HWND__ 
    +0x004 idFrom   : Uint4B 
    +0x008 code    : Uint4B 

64位:

0:000> dt tagNMHDR 
kernel32!tagNMHDR 
    +0x000 hwndFrom   : Ptr64 HWND__ 
    +0x008 idFrom   : Uint8B 
    +0x010 code    : Uint4B 
相關問題