本帖最后由 luofenghen 于 2010-06-29 12:16:38 编辑

解决方案 »

  1.   

    涉及方面有些乱,说不完,网上有很多代码,LZ可以去VBGOOD看看,有人写过。
      

  2.   

    以下是老马写的例子,帮我看看    pMyItemMemory = VirtualAllocEx(pHandle, 0, Len(myItem), MEM_COMMIT, PAGE_READWRITE)
    为什么返回的是0呢? Dim result              As Long
        Dim myItem              As LV_ITEMA
        Dim pHandle             As Long
        Dim pMyItemMemory       As Long
        Dim pStrBufferMemory    As Long
        Dim strBuffer()         As Byte
        Dim index               As Long
        Dim tmpString           As String
        Dim strLength           As Long
        
        ReDim strBuffer(MAX_LVMSTRING)
        
        pColumn = 1
        pRow = 20
        GetWindowThreadProcessId hWnd, processID
        pHandle = OpenProcess(PROCESS_ALL_ACCESS, False, processID)
        pStrBufferMemory = VirtualAllocEx(pHandle, Null, MAX_LVMSTRING, MEM_COMMIT, PAGE_READWRITE)
            
        myItem.mask = LVIF_TEXT
        myItem.iSubItem = pColumn
        myItem.pszText = pStrBufferMemory
        myItem.cchTextMax = MAX_LVMSTRING
        
        pMyItemMemory = VirtualAllocEx(pHandle, 0, Len(myItem), MEM_COMMIT, PAGE_READWRITE)
        result = WriteProcessMemory(pHandle, pMyItemMemory, myItem, Len(myItem), 0)
        ItemCount = SendMessage(hWnd, LVM_GETITEMCOUNT, 0, 0)
        result = SendMessage(hWnd, LVM_GETITEMTEXT, pRow, ByVal pMyItemMemory)
        
        result = ReadProcessMemory(pHandle, pStrBufferMemory, strBuffer(0), MAX_LVMSTRING, 0)
        result = ReadProcessMemory(pHandle, pMyItemMemory, myItem, Len(myItem), 0)    For index = LBound(strBuffer) To UBound(strBuffer)
            If Chr(strBuffer(index)) = vbNullChar Then Exit For
            tmpString = tmpString & Chr(strBuffer(index))
        Next index
        
        tmpString = Trim(tmpString)
        
        result = VirtualFreeEx(pHandle, pStrBufferMemory, 0, MEM_RELEASE)
        result = VirtualFreeEx(pHandle, pMyItemMemory, 0, MEM_RELEASE)
        
        result = CloseHandle(pHandle)
        
        If Len(tmpString) > 0 Then GetListviewItem = tmpString
      

  3.   

    看了VBGOOD 里的内容  有了新的想法  
     
       pStrBufferMemory = VirtualAlloc(Null, MAX_LVMSTRING, MEM_COMMIT, PAGE_READWRITE)
        
           
            
        myItem.mask = LVIF_TEXT
        myItem.iSubItem = pColumn
        myItem.pszText = pStrBufferMemory
        myItem.cchTextMax = MAX_LVMSTRING
        
    pMyItemMemory = VirtualAlloc(Null, Len(myItem), MEM_COMMIT, PAGE_READWRITE)
        result = WriteProcessMemory(pHandle, pMyItemMemory, myItem, Len(myItem), 0)
        ItemCount = SendMessage(hWnd, LVM_GETITEMCOUNT, 0, 0)
        result = SendMessage(hWnd, LVM_GETITEMTEXT, pRow, ByVal pMyItemMemory)'返回0 不成功
        result = SendMessage(hWnd, WM_LBUTTONDBLCLK, pRow, ByVal pMyItemMemory)'返回0 不成功
        result = SendMessage(pHandle, WM_LBUTTONDBLCLK, pRow, ByVal pMyItemMemory)'返回0 不成功不成功的3条怎么解决呢
      

  4.   


     ItemCount = SendMessage(hWnd, LVM_GETITEMCOUNT, 0, 0)
     lngHeaderHwnd = SendMessage(hWnd, LVM_GETHEADER, 0, 0)
     lngCols = SendMessage(lngHeaderHwnd, HDM_GETITEMCOUNT, 0, 0) '获取ListView表头项目数'上面3条能取到 
    result = SendMessage(hWnd, LVM_GETITEMTEXT, pRow, ByVal pMyItemMemory)'这条取不到 返回0
    为什么呢??
      

  5.   


     pStrBufferMemory = VirtualAllocEx(pHandle, 0, MAX_LVMSTRING, MEM_COMMIT, PAGE_READWRITE)  pMyItemMemory = VirtualAllocEx(pHandle, 0, Len(myItem), MEM_COMMIT, PAGE_READWRITE)2个值一样的~  有关系吗?
      

  6.   

    要类似这样写:
    dim pRow as string*256  
    result = SendMessage(hWnd, LVM_GETITEMTEXT, 256, pRow)
      

  7.   

    pRow是传进来的值  是从0到500之间的
      

  8.   

    还有,VB能不能发LVM_GETITEMTEXT,是个问题?
      

  9.   

    可以的  我用http://www.vbgood.com/viewthread.php?tid=69158这个实例试过  可以得到  但用WIN7的不能运行那个实例 我用测试机的XP试过
      

  10.   

    不同进程间获取控件信息需要在目标进程中分配内存,要用VirtualAllocEx。当前进程开启SeDebugPrivilege权限,否则OpenProcess(PROCESS_ALL_ACCESS...会失败。
      

  11.   

    lvSelected = SendMessage(hWndlistView, &H1000& + 66&, 0, ByVal 0&)   '获取列表的选定项索引 双击其实很麻烦, 你可以试试,那个listview是否支持回车之类的键盘快捷键,直接发个回车比双击简单多了