?? form1.frm
字號:
VERSION 5.00
Begin VB.Form Form1
Caption = "CRC32自校檢演示"
ClientHeight = 4500
ClientLeft = 60
ClientTop = 345
ClientWidth = 5010
LinkTopic = "Form1"
ScaleHeight = 4500
ScaleWidth = 5010
StartUpPosition = 2 '屏幕中心
Begin VB.TextBox Text4
Height = 270
Left = 1440
TabIndex = 13
Top = 2160
Width = 1095
End
Begin VB.CommandButton Command3
Caption = "讀取"
Height = 345
Left = 4440
TabIndex = 11
Top = 120
Width = 495
End
Begin VB.CommandButton Command1
Caption = "添加標識"
Enabled = 0 'False
Height = 375
Left = 1560
TabIndex = 10
Top = 2520
Width = 975
End
Begin VB.TextBox Text3
Height = 270
Left = 1440
TabIndex = 9
Top = 1800
Width = 1095
End
Begin VB.TextBox Text2
Height = 270
Left = 1440
TabIndex = 8
Top = 1440
Width = 1095
End
Begin VB.TextBox Text1
Height = 270
Left = 1440
OLEDropMode = 1 'Manual
TabIndex = 5
Top = 1080
Width = 1095
End
Begin VB.Label Label7
Caption = "特征碼標識:"
Height = 255
Left = 120
TabIndex = 12
Top = 2160
Width = 1095
End
Begin VB.Label Label6
Caption = "CRC32:"
Height = 255
Left = 120
TabIndex = 7
Top = 1800
Width = 855
End
Begin VB.Label Label5
Caption = "長度:"
Height = 255
Left = 120
TabIndex = 6
Top = 1440
Width = 975
End
Begin VB.Label Label4
Caption = "待處理文件:"
Height = 255
Left = 120
TabIndex = 4
Top = 1080
Width = 1095
End
Begin VB.Label Label3
Caption = "0"
Height = 255
Left = 3240
TabIndex = 3
Top = 240
Width = 1215
End
Begin VB.Label Label2
Caption = "0"
Height = 255
Left = 3240
TabIndex = 2
Top = 600
Width = 1575
End
Begin VB.Label Label1
Caption = "讀取后0位字節存儲的CRC為:"
Height = 255
Index = 2
Left = 120
TabIndex = 1
Top = 240
Width = 3015
End
Begin VB.Label Label1
Caption = "除去后0位字節后的CRC為:"
Height = 255
Index = 0
Left = 120
TabIndex = 0
Top = 600
Width = 3015
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Declare Function GetModuleFileName Lib "kernel32" Alias "GetModuleFileNameA" (ByVal hModule As Long, ByVal lpFileName As String, ByVal nSize As Long) As Long
'Better than App.EXEName because it also gets the extension
'(It's possible to run a program with any extension, not just .exe)
Private Function FullAppName() As String
Dim modName As String * 256
Dim i As Long
Dim j As Long
i = GetModuleFileName(App.hInstance, modName, Len(modName))
FullAppName = Left$(modName, i)
j = Len(FullAppName)
Do While Mid(FullAppName, j, 1) = vbNullChar
j = j - 1
Loop
FullAppName = Trim(Left(FullAppName, j))
End Function
Private Sub Command1_Click()
Dim sCRC32 As String
Dim FileNum As Integer
Dim bArry() As Byte
sCRC32 = "C:" & Text3.Text
bArry() = StrConv(sCRC32, vbFromUnicode)
FileNum = FreeFile
Open Text1.Text For Binary As #FileNum
Seek #FileNum, LOF(FileNum) + 1
Put #FileNum, , bArry
Close #FileNum
End Sub
Private Sub Command3_Click()
Dim cCRC32 As New cCRC32
Dim lCRC32 As Long
Dim cStream As New cBinaryFileStream
cStream.File = FullAppName
cStream.FileStart = 1
cStream.FileEnd = cStream.Length - 10
lCRC32 = cCRC32.GetFileCrc32(cStream)
Label2 = Hex(lCRC32)
Set cCRC32 = Nothing
Set cStream = Nothing
End Sub
Private Sub Text1_OLEDragOver(Data As DataObject, Effect As Long, Button As Integer, Shift As Integer, X As Single, Y As Single, State As Integer)
Text1 = Data.Files(1)
Dim i As Integer
Dim sCRC32 As String
Dim cCRC32 As New cCRC32
Dim lCRC32 As Long
Dim cStream As New cBinaryFileStream
cStream.File = Text1.Text
Text2 = cStream.Length
cStream.FileStart = 1
cStream.FileEnd = cStream.Length
lCRC32 = cCRC32.GetFileCrc32(cStream)
Text3 = Hex(lCRC32)
Text2 = cStream.Length
Set cCRC32 = Nothing
Set cStream = Nothing
Dim FileNum As Integer
Dim bArry(0 To 9) As Byte
FileNum = FreeFile
Open Text1.Text For Binary As #FileNum
Seek #FileNum, LOF(FileNum) - 9
Get #FileNum, , bArry
Close #FileNum
If Chr(bArry(0)) = "C" Then
For i = 2 To 9
sCRC32 = sCRC32 & Chr(bArry(i))
Next
Text4 = sCRC32
Command1.Enabled = False
Else
Text4 = "Found Nothing"
Command1.Enabled = True
End If
End Sub
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -