十年网站开发经验 + 多家企业客户 + 靠谱的建站团队
量身定制 + 运营维护+专业推广+无忧售后,网站问题一站解决
你用的WriteLine, Line就是行,所以会加换行符
成都创新互联是一家专注网站建设、网络营销策划、微信小程序定制开发、电子商务建设、网络推广、移动互联开发、研究、服务为一体的技术型公司。公司成立十载以来,已经为上千余家纯水机各业的企业公司提供互联网服务。现在,服务的上千余家客户与我们一路同行,见证我们的成长;未来,我们一起分享成功的喜悦。
如果用Sw1.Write("....");就不会换行
在写System.Windows.Forms.Clipboard.SetText时,提示是依系统,也就是说不一定可使用,鉴于是匿名提问就点到而止
vb.net 有专门的托盘图标控件 在工具箱里直接添加一个就可以了 两行代码即可
NotifyIcon1.Icon = Me.Icon
NotifyIcon1.Visible = True
在资源文件管理器中,找到数据库,属性管理器中出现属性,选择不复制,或当文件最新时才复制
这说明你调用 API 传参存在问题。
首先有没有设置结构体内存对齐?
[StructLayout(LayoutKind.Sequential)] 加了吗?
COLORREF 不要用 Color 代替,用 int 代替
TCHAR cfFaceName[32] 定义为 Byte 数组也可以,带在传参前,必须初始化为 32 个长度
Imports System.Runtime.InteropServices
Public Class MemoryEditor
Inherits WINAPI.NativeMethods
Private phwnd As IntPtr
Private Buffer As Byte()
Private BytesRead As IntPtr
Private BytesWrite As IntPtr
''' summary创建内存编辑器/summary
''' param name="processHwnd"进程句柄/param
Sub New(processHwnd As IntPtr)
Me.phwnd = processHwnd
End Sub
''' summary根据指定偏移量读取内存基址/summary
''' param name="addr"内存地址/param
''' param name="offsets"偏移量数组/param
Public Function ReadBaseAddress(addr As IntPtr, offsets() As Integer) As IntPtr
Dim address As IntPtr = ReadMemoryToInteger(addr)
For Each offset As Integer In offsets
address = address.ToInt32 + offset
address = ReadMemoryToInteger(address)
If address = IntPtr.Zero Then
Dim errInfo As String = "内存偏移量[" Hex(offset) "]错误!"
Throw New Exception(errInfo)
End If
Next
Return address
End Function
''' summary读取4字节内存数值/summary
''' param name="addr"内存地址/param
Public Function ReadMemoryToInteger(addr As IntPtr) As Integer
Buffer = New Byte(3) {}
ReadProcessMemory(phwnd, addr, Buffer, 4, BytesRead)
Return BitConverter.ToInt32(Buffer, 0)
End Function
''' summary读取4字节内存数组/summary
''' param name="addr"内存地址/param
Public Function ReadMemoryToBytes(addr As IntPtr) As Byte()
Buffer = New Byte(3) {}
ReadProcessMemory(phwnd, addr, Buffer, 4, BytesRead)
Return Buffer
End Function
''' summary将内存值数组写入指定地址/summary
''' param name="addr"内存地址/param
''' param name="buffer"内存值数组/param
Public Function WriteMemoryByBytes(addr As IntPtr, buffer As Byte()) As Boolean
Return WriteProcessMemory(phwnd, addr, buffer, buffer.Length, BytesWrite)
End Function
End Class
Namespace WINAPI
Public MustInherit Class NativeMethods
DllImport("kernel32.dll", SetLastError:=True) _
Public Shared Function ReadProcessMemory(ByVal hProcess As IntPtr, _
ByVal lpBaseAddress As IntPtr, _
Out() ByVal lpBuffer() As Byte, _
ByVal dwSize As Integer, _
ByRef lpBytesRead As Integer) As Boolean
End Function
DllImport("kernel32.dll", SetLastError:=True) _
Public Shared Function WriteProcessMemory(ByVal hProcess As IntPtr, _
ByVal lpBaseAddress As IntPtr, _
ByVal lpBuffer As Byte(), _
ByVal nSize As Integer, _
Out() ByRef lpBytesWritten As IntPtr) As Boolean
End Function
End Class
End Namespace
是不是内存读写代码有问题!用上面的代码试试,我以前写的;
调用方法:
Dim mem As New MemoryEditor(进程句柄)
Dim offsets As Integer() = {H1, H2, H3} '{一级基址,二级基址,三级基址}
Dim baseaddr As IntPtr = mem.ReadBaseAddress(内存地址, offsets)
Dim value As Integer = mem.ReadMemoryToInteger(baseaddr)