FrmZHexView.frm
====================================================================
VERSION 5.00
Object = "{3B7C8863-D78F-101B-B9B5-04021C009402}#1.2#0"; "RICHTX32.OCX"
Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "COMDLG32.OCX"
Begin VB.Form FrmZHexView
Caption = "ZHexView"
ClientHeight = 3195
ClientLeft = 60
ClientTop = 345
ClientWidth = 4680
LinkTopic = "Form1"
LockControls = -1 'True
ScaleHeight = 3195
ScaleWidth = 4680
StartUpPosition = 3 '窗口缺省
Begin MSComDlg.CommonDialog CDlg1
Left = 2100
Top = 1350
_ExtentX = 847
_ExtentY = 847
_Version = 393216
CancelError = -1 'True
End
Begin RichTextLib.RichTextBox RText1
Height = 1245
Left = 0
TabIndex = 2
Top = 330
Width = 2115
_ExtentX = 3731
_ExtentY = 2196
_Version = 393217
HideSelection = 0 'False
ScrollBars = 3
DisableNoScroll = -1 'True
RightMargin = 1e7
TextRTF = $"FrmZHexView.frx":0000
End
Begin VB.TextBox TxtFile
Height = 285
Left = 570
TabIndex = 1
Text = "Text1"
ToolTipText = "文件名"
Top = 0
Width = 4035
End
Begin VB.Label Lbl1
AutoSize = -1 'True
Caption = "打开:"
Height = 180
Left = 30
TabIndex = 0
Top = 30
Width = 540
End
End
Attribute VB_Name = "FrmZHexView"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private Const MeText = "ZHexView"
Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (Destination As Any, Source As Any, ByVal Length As Long)
Private Declare Function timeGetTime Lib "winmm.dll" () As Long
Private Sub Form_Load()
'Dim S1 As String, S2 As String * 3
'
'S1 = Space$(3)
'S2 = "03 "
'Call CopyMemory(ByVal StrPtr(S1), ByVal StrPtr(S2), 6)
'
'Debug.Print S1
CDlg1.Flags = cdlOFNFileMustExist Or cdlOFNHideReadOnly
CDlg1.Filter = "文本文件(*.txt)|*.txt|所有文件(*.*)|*.*"
End Sub
Private Sub Form_Resize()
If Me.WindowState = 1 Then Exit Sub
Private Sub TxtFile_KeyPress(KeyAscii As Integer)
If KeyAscii = vbKeyReturn Then
LoadHex TxtFile.Text
End If
End Sub
Private Sub LoadHex(FileStr As String)
Dim LoadBytes() As Byte
Dim FileNum As Integer
Dim FileSize As Long
Dim ArrayMax As Long
Dim AllStr As String
Dim TempStr As String
Dim TempPtr As Long
Dim I As Long, J As Long
Dim MaxI As Long
Dim Offset As Long
Dim StrOff As Long
Dim TimeLng As Long
FileNum = FreeFile
On Error GoTo ErrLoad
Open TxtFile.Text For Binary Access Read Lock Write As #FileNum
On Error GoTo 0