API获取其他应用程序中的LISTview的项,用到什么函数,或者有代码的更好

API获取其他应用程序中的LISTview的项,用到什么函数,或者有代码的更好,第1张

有点长,慢慢看吧

Begin VBForm frmMain

Caption = "Form1"

ClientHeight = 3090

ClientLeft = 60

ClientTop = 450

ClientWidth = 4680

LinkTopic = "Form1"

ScaleHeight = 3090

ScaleWidth = 4680

StartUpPosition = 3 '窗口缺省

Begin VBCommandButton Command1

Caption = "Command1"

Height = 975

Left = 1320

TabIndex = 0

Top = 1080

Width = 2415

End

End

Attribute VB_Name = "frmMain"

Attribute VB_GlobalNameSpace = False

Attribute VB_Creatable = False

Attribute VB_PredeclaredId = True

Attribute VB_Exposed = False

Option Explicit

Private Const MEM_RELEASE = &H8000

Private Const LVM_FIRST = &H1000

Private Const LVM_GETHEADER = LVM_FIRST + 31

Private Const LVM_GETITEMCOUNT = (LVM_FIRST + 4)

Private Const LVM_GETITEM = (LVM_FIRST + 5)

Private Const LVM_GETSTRINGWIDTH = (LVM_FIRST + 17)

Private Const LVM_GETCOLUMN = (LVM_FIRST + 25)

Private Const LVM_GETITEMTEXT = (LVM_FIRST + 45)

Private Const HDM_FIRST = &H1200

Private Const HDM_GETITEMCOUNT = (HDM_FIRST + 0)

Private Const HDM_ORDERTOINDEX = (HDM_FIRST + 15)

Private Const PROCESS_QUERY_INFORMATION = 1024

Private Const PROCESS_VM_OPERATION = &H8

Private Const PROCESS_VM_READ = &H10

Private Const PROCESS_VM_WRITE = &H20

Private Const STANDARD_RIGHTS_REQUIRED = &HF0000

Private Const MAX_LVMSTRING As Long = 255

Private Const MEM_COMMIT = &H1000

Private Const PAGE_READWRITE = &H4

Private Const LVIF_TEXT As Long = &H1

Private Const LVM_GETCOLUMNCOUNT = &HF11B

Private Type LV_ITEMA

mask As Long

iItem As Long

iSubItem As Long

state As Long

stateMask As Long

pszText As Long

cchTextMax As Long

iImage As Long

lParam As Long

iIndent As Long

End Type

Private Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcId As Long) As Long

Private Declare Function VirtualAllocEx Lib "kernel32" (ByVal hProcess As Long, ByVal lpAddress As Long, ByVal dwSize As Long, ByVal flAllocationType As Long, ByVal flProtect As Long) As Long

Private Declare Function VirtualFreeEx Lib "kernel32" (ByVal hProcess As Long, ByVal lpAddress As Long, ByVal dwSize As Long, ByVal dwFreeType As Long) As Long

Private Declare Function WriteProcessMemory Lib "kernel32" (ByVal hProcess As Long, ByVal lpBaseAddress As Any, ByRef lpBuffer As Any, ByVal nSize As Long, lpNumberOfBytesWritten As Long) As Long

Private Declare Function ReadProcessMemory Lib "kernel32" (ByVal hProcess As Long, ByVal lpBaseAddress As Any, ByRef lpBuffer As Any, ByVal nSize As Long, lpNumberOfBytesWritten As Long) As Long

Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByRef lParam As Any) As Long

Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long

Private Declare Function GetCurrentProcessId Lib "kernel32" () As Long

Private Function GetListViewTextArray(ByVal hWindow As Long, ByVal ProcessID As Long) As String()

Dim result As Long

Dim myItem() As LV_ITEMA

Dim pHandle As Long

Dim pStrBufferMemory As Long

Dim pMyItemMemory As Long

Dim strBuffer() As Byte

Dim index As Long

Dim tmpString As String

Dim strLength As Long

Dim i As Integer, sum As Integer, j As Integer, hCount As Long

Dim strArr() As String, itemString As String

hCount = SendMessage(hWindow, LVM_GETHEADER, 0, 0)

If hCount > 0 Then

hCount = SendMessage(hCount, HDM_GETITEMCOUNT, 0, 0)

Else

hCount = 0

End If

ReDim strBuffer(MAX_LVMSTRING)

pHandle = OpenProcess(PROCESS_VM_OPERATION Or PROCESS_VM_READ Or PROCESS_VM_WRITE, False, ProcessID)

ReDim myItem(hCount)

For j = 0 To SendMessage(hWindow, LVM_GETITEMCOUNT, 0, 0) - 1

For i = 0 To hCount

pStrBufferMemory = VirtualAllocEx(pHandle, 0, MAX_LVMSTRING, MEM_COMMIT, PAGE_READWRITE)

myItem(i)mask = LVIF_TEXT

myItem(i)iSubItem = i

myItem(i)pszText = pStrBufferMemory

myItem(i)cchTextMax = MAX_LVMSTRING

pMyItemMemory = VirtualAllocEx(pHandle, 0, Len(myItem(i)), MEM_COMMIT, PAGE_READWRITE)

result = WriteProcessMemory(pHandle, pMyItemMemory, myItem(i), Len(myItem(i)), 0)

result = SendMessage(hWindow, LVM_GETITEMTEXT, j, ByVal 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(i), Len(myItem(i)), 0)

tmpString = StrConv(strBuffer, vbUnicode)

tmpString = Left(tmpString, InStr(tmpString, vbNullChar) - 1)

itemString = itemString & tmpString & ","

result = VirtualFreeEx(pHandle, pStrBufferMemory, 0, MEM_RELEASE)

result = VirtualFreeEx(pHandle, pMyItemMemory, 0, MEM_RELEASE)

Next

ReDim Preserve strArr(0 To sum)

strArr(j) = Left(itemString, Len(itemString) - 1)

sum = sum + 1

itemString = ""

Next

result = CloseHandle(pHandle)

GetListViewTextArray = strArr

End Function

Private Sub Command1_Click()

Dim itemStr() As String, i As Integer

itemStr = GetListViewTextArray(frmListViewlvTesthwnd, GetCurrentProcessId)

For i = 0 To UBound(itemStr)

MsgBox itemStr(i)

Next

End Sub

Private Sub Form_Load()

frmListViewShow

End Sub

VERSION 500

Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#20#0"; "MSCOMCTLOCX"

Begin VBForm frmListView

Caption = "测试窗体"

ClientHeight = 5730

ClientLeft = 60

ClientTop = 450

ClientWidth = 7425

LinkTopic = "Form2"

ScaleHeight = 5730

ScaleWidth = 7425

StartUpPosition = 3 '窗口缺省

Begin MSComctlLibListView lvTest

Height = 4695

Left = 360

TabIndex = 0

Top = 480

Width = 6495

_ExtentX = 11456

_ExtentY = 8281

View = 3

LabelWrap = -1 'True

HideSelection = -1 'True

_Version = 393217

ForeColor = -2147483640

BackColor = -2147483643

BorderStyle = 1

Appearance = 1

NumItems = 0

End

End

Attribute VB_Name = "frmListView"

Attribute VB_GlobalNameSpace = False

Attribute VB_Creatable = False

Attribute VB_PredeclaredId = True

Attribute VB_Exposed = False

Private Sub Form_Load()

With lvTest

ColumnHeadersAdd , , "序号"

ColumnHeadersAdd , , "名称"

ColumnHeadersAdd , , "性别"

ColumnHeadersAdd , , "年龄"

End With

AddToListview "陈辉", "男", "24"

AddToListview "张三", "男", "22"

AddToListview "李四", "女", "20"

AddToListview "王二", "男", "31"

AddToListview "麻子", "女", "18"

End Sub

Private Sub AddToListview(ByVal sName As String, sSex As String, ByVal sAge As String)

Dim item As ListItem

Set item = lvTestListItemsAdd(, , CStr(lvTestListItemsCount + 1))

itemSubItems(1) = sName

itemSubItems(2) = sSex

itemSubItems(3) = sAge

End Sub

Abstract Syntax Notation dot one,抽象语法标记,描述了一种对数据进行表示、传输和解码的数据格式。它提供了一整套正规的格式用于描述对象的结构。它包含两部分:一部分描述信息内数据,数据类型及序列格式;另一部分描述如何将各部分组成消息。而不管语言上如何执行及这些数据的具体指代,也不用去管到底是什么样的应用程序;

ASN1有很多实现版本,Openssl主要采用DER格式,ASN1相关的头文件参见Openssl的源码 asn1h、asn1th,如下所示:

ANS1字段含义:

length —— 管理的数据长度

type —— 管理的数据类型。

data —— 数据指针。

flags —— 标志位,跟具体数据类型有关

TLV结构即:Type类型, Lenght长度,Value值;它是一种可变格式;Type和Length的长度固定,一般那是2、4个字节;Value的长度由Length指定;

在一段TLV结构描述的数据中例如RSA密钥:

接下来按照TLV格式来分析Openssl所生成的der格式的2048位私钥,这里先说明一下pem格式的密钥和der格式的密钥的区别仅仅在于将der格式的密钥进行base64编码之后加上表头和结尾即为pem格式;

可见私钥当中包含了n、e、d值,所以理论上可以使用私钥进行加密和解密,而在一些加密锁的厂家为了节省内存,会对私钥进行删减,仅仅保留相关解密的参数;

私钥的二进制数据按照TLV结构排列如下:

Openssl查看密钥参数如下:

这里我们大致可以看出TLV结构中的Value和上述过程中的各个参数一致,但是需要说明的是Openssl在查看密钥参数时,已经做了处理保证了modulus、p、q之类有符号位的大数不为负数;所以当我们自己根据这各个参数进行拼接der格式时,具体的方法应当参见上述TLV结构说明;

30 :Type

04A2: 下面内容总长度,超过了0xFF,所以用两个字节描述,所以第二个字节为82,如果下面总长度没有超过0xFF,只用一个字节可以描述,则为81

02:表示asn1_string_st中的type

81:表示长度大于0x80,同时只用一个字节就可以描述

81:参数长度

02:表示asn1_string_st中的type

82:表示长度大于0xFF,需要用两个字节描述

0100:参数长度

02:表示asn1_string_st中的type

03:表示长度是3,小于0x80

基于TLV2542的双通道数字电压表程序设计 简介:基于TLV2542的双通道数字电压表采用AVR单片机ATMEGA16作为主控芯片,数模转换采用TI公司生产的带自动掉电的、低功耗、12位、双通道串行模/数转换器TLV2542,采集后的电压值在带字库的字符型液晶12864上显示。编程采用AVR Studio4+WinAVR构成的GCC编译环境。 系统源程序及其注释如下所示: /AVR单片机ATMEGA16在GCC下编程,/ /完成tlv2542双通道ADC的编程,/ /并将ADC采样的值送12864显示/ #define F_CPU 2000000UL #include <avr/ioh> #include <util/delayh> #include <mathh> #include <avr/interrupth> #define nop() asm("NOP") /液晶显示引脚定义/

en_1; _delay_us(200); busy_0; while((PINB&0x80)==1) ; en_0; busy_1; } /写命令/ void write_com(unsigned char cmd) { checkbusy(); rs_0; rw_0; en_1; _delay_us(1); PORTB=cmd; _delay_us(2); en_0; } /写数据/ void write_date(unsigned char dat)

{ checkbusy(); rs_1; rw_0; en_1; _delay_us(2); PORTB=dat; _delay_us(2); en_0; } /液晶初始化/ void init_lcd() { DDRB=0xff; PORTB=0xff; DDRD=0xff; PORTB=0xff; write_com(0x30); _delay_us(2); write_com(0x0c); _

没有用过TLC2552,但是从时序图上可以看出,要想使它工作,首先得在CLK端给一个脉冲信号。在CS的下降沿开始读或者写数据。在有脉冲的前提下,先把CS端电平变为1,如果是读数据的话,那么就在CS变为低电平之后一段时间后读取数据。如果是写数据,那么就在CS变为低电平以后,把要写的数据给数据端。

几乎所有的需要在卡片和终端之间传送的数据都是TLV格式的

我给你举个例子方便快速理解:

TLV 是 tag , length 和 value 的缩写一个基本的数据元就包括上面三个域 Tag 唯一标识该数据元, length 是 value 域的长度 Value就是数据本身了 举个例子, 下面是一个tlv格式的AID(应用标识符)字节串” 9F0607A0000000031010 ”, 其中 9F06 是tag, 07 是长度, A0000000031010 就是AID本身的值了

对于程序编写人员来说,如果有类似上面这样的一串TLV编码的字节串从卡片传过来, 怎么样从中提取我们想要的数据 这就牵扯出TLV解码的问题了

TLV一种可变格式,TLV的意思就是:Type类型, Lenght长度,Value值;

Type和Length的长度固定,一般那是2、4个字节;

Value的长度有Length指定;

解析方法:

1读取type 转换为ntohl、ntohs转换为主机字节序得到类型;指针偏移+2或4

2读取lenght,转换为ntohl、ntohs转换为主机字节序得到长度;指针偏移+2或4

3根据得到的长度读取value,指针偏移+Length;

TLV编码就是指先对Tag编码,再对Length编码,最后对Value编码。

以上就是关于API获取其他应用程序中的LISTview的项,用到什么函数,或者有代码的更好全部的内容,包括:API获取其他应用程序中的LISTview的项,用到什么函数,或者有代码的更好、Openssl库之RSA格式解析、关于数字电压表 12864引脚连接的问题等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zz/9277598.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-04-26
下一篇 2023-04-26

发表评论

登录后才能评论

评论列表(0条)

保存