VB如何在内存中操作文件?
发布网友
发布时间:2022-04-22 14:54
我来回答
共3个回答
热心网友
时间:2022-07-12 07:32
花了点时间给你给个实例你慢慢研究下吧
声明:
Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" _
(Destination As Any, Source As Any, ByVal Length As Long)
'lpt 已知的内存地址
'size 欲读取的内存大小
'注:copymemory调用的方式为过程调用,不能有返回值
'copymemory传递source本身是按地址传递,但此处要按值传递指针(欺骗vb,vb仍然认为传递的是地址)
'代码:
Function Getvalue(lpt As Long, size As Long)
Dim x '用于读出的结果存放变量
CopyMemory x, ByVal lpt, ByVal size
Getvalue = x
End Sub
热心网友
时间:2022-07-12 07:32
能啊
Public Function GetData(ByVal lppid As Long, ByVal lpAddress As Long, SaveData() As Byte, Optional ByVal dtLen As Long = 4)
Dim pHandle As Long ' 储存进程句柄
' 使用进程标识符取得进程句柄
pHandle = OpenProcess(PROCESS_ALL_ACCESS, False, lppid)
' 在内存地址中读取数据
ReadProcessMemory pHandle, ByVal lpAddress, ByVal VarPtr(SaveData(0)), dtLen, 0&
' 关闭进程句柄
CloseHandle pHandle
End Function
上面的是模块里的..
然后我在别的窗体代码里写了
GamePid = GetPid(vbNullString, "form1")
Dim ss(2) As Byte
ss(0) = &H0
GetData GamePid, &H400000, ss, 2
热心网友
时间:2022-07-12 07:33
Public Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (Destination As Any, Source As Any, ByVal Length As Long)
用这个api函数就可以转换内存文件,然后操作操作