开发者技术变现资源聚集地

https://www.baiydu.com


Public Class Form1
Public Const LVM_FIRST As Short = &H1000S
Public Const LVM_GETITEMCOUNT As Integer = (LVM_FIRST + 4)
Public Const LVM_GETITEM As Integer = (LVM_FIRST + 5)
Public Const LVM_GETSTRINGWIDTH As Integer = (LVM_FIRST + 17)
Public Const LVM_GETCOLUMN As Integer = (LVM_FIRST + 25)
Public Const LVM_GETITEMTEXT As Integer = (LVM_FIRST + 45)
Public Const LVM_GETHEADER As Integer = LVM_FIRST + 31
Public Const WC_HEADERA As String = "SysHeader32"
Public Const WC_HEADER As String = WC_HEADERA
Public Const HDM_FIRST As Short = &H1200S '// Header messages
Public Const HDM_GETITEMCOUNT As Integer = (HDM_FIRST + 0)
Public Const HDM_ORDERTOINDEX As Integer = (HDM_FIRST + 15)
Public Const PROCESS_QUERY_INFORMATION As Short = 1024
Public Const PROCESS_VM_OPERATION As Short = &H8S
Public Const PROCESS_VM_READ As Short = &H10S
Public Const PROCESS_VM_WRITE As Short = &H20S
Public Const STANDARD_RIGHTS_REQUIRED As Integer = &HF0000
Public Const MAX_LVMSTRING As Integer = 255 '可根椐读取数据长度设置适当的数值
Public Const MEM_COMMIT As Short = &H1000S
Public Const MEM_RELEASE As Short = &H8000S
Public Const PAGE_READWRITE As Short = &H4S
Public Const LVIF_TEXT As Integer = &H1S
Public Structure LV_ITEMA
Dim mask As Integer
Dim iItem As Integer
Dim iSubItem As Integer
Dim state As Integer
Dim stateMask As Integer
Dim pszText As Integer
Dim cchTextMax As Integer
Dim iImage As Integer
Dim lParam As Integer
Dim iIndent As Integer
End Structure Private Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Integer, ByVal bInheritHandle As Integer, ByVal dwProcId As Integer) As Integer
Private Declare Function VirtualAllocEx Lib "kernel32" (ByVal hProcess As Integer, ByVal lpAddress As Integer, ByVal dwSize As Integer, ByVal flAllocationType As Integer, ByVal flProtect As Integer) As Integer
Private Declare Function VirtualFreeEx Lib "kernel32" (ByVal hProcess As Integer, ByVal lpAddress As Integer, ByVal dwSize As Integer, ByVal dwFreeType As Integer) As Integer Private Declare Function WriteProcessMemory Lib "kernel32" (ByVal hProcess As Integer, ByVal lpBaseAddress As Integer, ByRef lpBuffer As LV_ITEMA, ByVal nSize As Integer, ByVal lpNumberOfBytesWritten As Integer) As Integer Private Declare Function ReadProcessMemory Lib "kernel32" (ByVal hProcess As Integer, ByVal lpBaseAddress As Object, ByRef lpBuffer As Object, ByVal nSize As Integer, ByVal lpNumberOfBytesWritten As Integer) As Integer Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Integer, ByVal wMsg As Integer, ByVal wParam As Integer, ByVal lParam As Integer) As Integer Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Integer) As Integer
Private Declare Function GetCurrentProcessId Lib "kernel32" () As Integer
Public Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Integer
Public Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Integer, ByVal hWnd2 As Integer, ByVal lpsz1 As String, ByVal lpsz2 As String) As Integer
Public Declare Function GetWindowThreadProcessId Lib "user32" Alias "GetWindowThreadProcessId" (ByVal hwnd As Integer, ByRef lpdwProcessId As Integer) As Integer Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim lngHwnd As Integer
Dim lngHwnd0 As Integer
Dim lngHwnd1 As Integer
Dim lngHeaderHwnd As Integer
Dim lngPId As Integer
Dim lngRows As Integer
Dim lngCols As Integer
Dim lngRow As Integer
Dim lngCol As Integer
Dim strItem As String lngHwnd = FindWindow("#32770", "Windows 任务管理器")
lngHwnd0 = FindWindowEx(lngHwnd, 0, "#32770", "Applications") '获取任务管理器窗口句柄 lngHwnd1 = FindWindowEx(lngHwnd0, 0, "SysListView32", "任务") '获取进程列表框句柄 'lngHwnd0 = FindWindowEx(lngHwnd, 0, "WTWindow", "巅峰批量卡iPhone新版 V1.8")
'lngHwnd1 = FindWindowEx(lngHwnd0, 0, "SysListView32", "")
'第二个参数是 LVM_GETHEADER,获得LISTVIEW的HEADER句柄
lngHeaderHwnd = SendMessage(lngHwnd1, LVM_GETHEADER, 0, 0) lngRows = SendMessage(lngHwnd1, LVM_GETITEMCOUNT, 0, 0) '获取ListView项目数
Debug.Print("总行数是:" & lngRows) If lngHeaderHwnd > 0 Then
lngCols = SendMessage(lngHeaderHwnd, HDM_GETITEMCOUNT, 0, 0) '获取ListView表头项目数
Debug.Print("总列数是:" & lngCols) Else
lngCols = 1
End If GetWindowThreadProcessId(lngHwnd, lngPId) '获取与指定窗口关联在一起的一个进程和线程标识符ID Dim count As Integer Dim strBuffer() As Byte, pHandle As Integer, myItem() As LV_ITEMA, i As Integer, j As Integer
Dim pStrBufferMemory As Integer, pMyItemMemory As Integer, result As Integer, tmpString As String
Dim strLength As Integer ReDim strBuffer(MAX_LVMSTRING) pHandle = OpenProcess(PROCESS_VM_OPERATION Or PROCESS_VM_READ Or PROCESS_VM_WRITE, False, lngPId) ReDim myItem(lngCols) For i = 0 To lngRows - 1
For j = 0 To lngCols
pStrBufferMemory = VirtualAllocEx(pHandle, 0, MAX_LVMSTRING, MEM_COMMIT, PAGE_READWRITE)
myItem(j).mask = LVIF_TEXT
myItem(j).iSubItem = j
myItem(j).pszText = pStrBufferMemory
myItem(j).cchTextMax = MAX_LVMSTRING
pMyItemMemory = VirtualAllocEx(pHandle, 0, Len(myItem(j)), MEM_COMMIT, PAGE_READWRITE)
result = WriteProcessMemory(pHandle, pMyItemMemory, myItem(j), Len(myItem(j)), 0&) strLength = SendMessage(lngHwnd1, LVM_GETITEMTEXT, i, pMyItemMemory)
If result = 0 Then
result = VirtualFreeEx(pHandle, pStrBufferMemory, 0, MEM_RELEASE)
result = VirtualFreeEx(pHandle, pMyItemMemory, 0, MEM_RELEASE)
Exit For
End If
result = ReadProcessMemory(pHandle, pStrBufferMemory, strBuffer(0), MAX_LVMSTRING, 0)
result = ReadProcessMemory(pHandle, pMyItemMemory, myItem(j), Len(myItem(j)), 0)
tmpString = StrConv(System.Text.Encoding.Default.GetString(strBuffer), 0) result = VirtualFreeEx(pHandle, pStrBufferMemory, 0, MEM_RELEASE)
result = VirtualFreeEx(pHandle, pMyItemMemory, 0, MEM_RELEASE) Next Next result = CloseHandle(pHandle) End Sub End Class

  

vb.net WIN32API 获取listview的值的更多相关文章

  1. 如何获取listview里面的edittext或者RadioGroup的值,涉及到引发的混乱现象

    最近要实现从数据库读数据,该数据对应listview的item布局里面的RadioButton值,并且item布局里面还有EditText的控件. 如何将每一条对应的listview对应值获取出来呢? ...

  2. c# winform 获取listview 选中行某列的值

    给listview填充数据: for (int i = 0; i < 5; i++) { ListViewItem lvitem = new ListViewItem(); lvitem.Sub ...

  3. WPF 获取 ListView DataTemplate 中控件值

    原文:WPF 获取 ListView DataTemplate 中控件值 版权声明:本文为博主原创文章,未经博主允许可以随意转载 https://blog.csdn.net/songqingwei19 ...

  4. UWP 双向绑定,在ListView中有个TextBox,怎么获取Text的值

    要求:评论宝贝的时候一个订单里面包含多个产品,获取对产品的评论内容哦 1. xaml界面 <ListView x:Name="lvDetail"> <ListVi ...

  5. grails项目获取前后台的值

    grails项目中前台传值给后台: 加入我有a.gsp这个页面,a.gsp中有如下代码: 姓名:<input type="text" name="xing" ...

  6. C#获取存储过程返回值和输出参数值的方法

    //转自网络,先留个底 1.获取Return返回值 //存储过程 //Create PROCEDURE MYSQL // @a int, // @b int //AS // return @a + @ ...

  7. 在java中获取attr的值

    首先说如何获取已经在style里面定义好的attr的值,以colorPrimary为例: TypedValue value = new TypedValue(); mContext.getTheme( ...

  8. Python从线程获取函数返回值

    Python中利用强大的threading模块可以很容易的实现多线程开发,提高运行速度.这一般是对某个进行大量计算操作的的函数进行多线程处理,然后合并各线程的结果.获取函数返回值的方法可以如下: 1) ...

  9. RadGrid使用技巧:从RadGrid获取绑定的值

    本文主要介绍从RadGrid获取绑定的值,仅适用于Telerik RadControls for asp.net ajax. 获取方式 RadGrid把绑定的值存储在VIewState中,即使View ...

随机推荐

  1. ubuntu16中部署web项目到tomcat,xft和securecrt连接到ubuntu16(待续。。。)

    xftp    xftp中新建连接    ubuntu中安装和启动ssh服务    xftp连接到ubuntu 安装JDK,Tomcat    sudo tar -zvxf jdk.tar.gz   ...

  2. 左手是“Python”的身体,右手是“R”的灵魂,你爱哪个?

    来源商业新知网,原标题:你爱 “Python”的身体,还是“R”的灵魂? 数据科学界有三大宝: Python.SAS和R,不过像SAS这种高端物种,不是我们这些平民能供养得起的啊. 根据 IEEE S ...

  3. ES6-你不知道的箭头函数

    一谈到ES6的箭头函数,大家可能想到的优点就是语法更简洁,因为去掉了return.function.{}等输入. 但是设计者果真就是出于简洁的目的推出的箭头函数吗?显然不是.   => 箭头函数 ...

  4. python day07笔记总结

    2019.4.4 S21  day07笔记总结 一.深浅拷贝 1.copy.copy()     浅拷贝 deep.copy()    深拷贝 2.一般情况 1.str/int/bool 是不可变类型 ...

  5. S19 文件详解

    http://blog.csdn.net/finewind/article/details/5483554

  6. cnpm install -g live-server 安装服务

    cnpm  install -g live-server     指令会在浏览器自动打开页面

  7. Java第二周作业

    Java第二周作业 本周作业: 参考http://www.cnblogs.com/rocedu/p/7911138.html 学习第二三章视频 参考http://www.cnblogs.com/roc ...

  8. JS——按钮点击事件累加注册问题

    最近在工作上遇到一个点击事件累加的问题,为元素添加点击事件效果,但是总是效果失败,最后发现点击事件被执行了多次,上网查了一下,下边就是解决这个问题的几种思路 案列引自 踮起脚尖眺望6 $(" ...

  9. 使用FFmpeg解码并用swscale将YUV转为RGB

    #include <stdio.h> #include <libavcodec/avcodec.h> #include <libavformat/avformat.h&g ...

  10. 关于iOS刷新UI需要在主线程执行

    为什么一定要在主线程刷新UI? 安全+效率:因为UIKit框架不是线程安全的框架,当在多个线程进行UI操作,有可能出现资源抢夺,导致问题. 其实:在子线程是不能更新UI的, 看到能更新的结果只是个假象 ...