📄 frmmain.frm
字号:
VERSION 5.00
Object = "{648A5603-2C6E-101B-82B6-000000000014}#1.1#0"; "MSCOMM32.OCX"
Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "Comdlg32.ocx"
Begin VB.Form frmMain
Caption = "MegaLoader V0.6 Change every thing!"
ClientHeight = 6420
ClientLeft = 60
ClientTop = 345
ClientWidth = 10320
ClipControls = 0 'False
LinkTopic = "Form1"
MaxButton = 0 'False
ScaleHeight = 6420
ScaleWidth = 10320
StartUpPosition = 2 '屏幕中心
WhatsThisHelp = -1 'True
Begin VB.Timer Timer1
Interval = 1000
Left = 120
Top = 2280
End
Begin VB.TextBox txtFile
BeginProperty Font
Name = "宋体"
Size = 15.75
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 855
Left = 960
MultiLine = -1 'True
TabIndex = 12
ToolTipText = "文件路径"
Top = 1560
Width = 6855
End
Begin VB.CommandButton cmdCloseCom
Caption = "&close com"
Height = 375
Left = 8040
TabIndex = 10
Top = 3120
Width = 1215
End
Begin VB.CommandButton cmdOpenCom
Caption = "&open com"
Height = 375
Left = 8040
TabIndex = 9
Top = 2520
Width = 1215
End
Begin VB.CommandButton cmdExit
Caption = "e&xit"
Height = 375
Left = 8040
TabIndex = 8
Top = 3720
Width = 1215
End
Begin VB.ComboBox Combo2
Height = 300
Left = 4440
TabIndex = 7
Text = "19200"
Top = 960
Width = 2535
End
Begin VB.ComboBox Combo1
Height = 300
Left = 960
TabIndex = 5
Text = "COM1"
Top = 960
Width = 2655
End
Begin MSComDlg.CommonDialog dlgFile
Left = 120
Top = 1440
_ExtentX = 847
_ExtentY = 847
_Version = 393216
End
Begin VB.CommandButton cmdFree
Caption = "Free"
Height = 375
Left = 3720
TabIndex = 4
Top = 5160
Width = 1095
End
Begin VB.CommandButton cmdWrite
Caption = "Write!"
Height = 375
Left = 1200
TabIndex = 3
Top = 5160
Width = 1095
End
Begin VB.CommandButton cmdFlashFile
Caption = "FlashFile"
Height = 375
Left = 8040
TabIndex = 0
Top = 1920
Width = 1215
End
Begin MSCommLib.MSComm MSComm1
Left = 0
Top = 240
_ExtentX = 1005
_ExtentY = 1005
_Version = 393216
DTREnable = -1 'True
End
Begin VB.Frame Frame1
Caption = "芯片烧写控制"
Height = 1455
Left = 840
TabIndex = 11
Top = 4560
Width = 7335
Begin VB.CommandButton cmdrest
Caption = "&reset"
Height = 375
Left = 5160
TabIndex = 13
Top = 600
Width = 1215
End
End
Begin VB.Label Label1
Caption = "Label1"
Height = 375
Left = 840
TabIndex = 6
Top = 360
Width = 5775
End
Begin VB.Label lblMsg
Caption = "状态"
BeginProperty Font
Name = "宋体"
Size = 15
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H000000FF&
Height = 855
Left = 960
TabIndex = 2
Top = 2640
Width = 6735
End
Begin VB.Label lblChip
Caption = "芯片信息"
BeginProperty Font
Name = "宋体"
Size = 12
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00FF0000&
Height = 495
Left = 960
TabIndex = 1
Top = 3840
Width = 6255
End
End
Attribute VB_Name = "frmMain"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim ComSelCnt, BaudRateSelCnt As String
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Dim FlashBuf() As Byte
Dim lFile As Long
Dim iWaitChar As Long
Dim iPage As Long
Dim iErr As Long
Dim iPageByte As Long
Dim iPageMax As Long
Dim dTime As Double
Function CompFile(F1 As String, F2 As String) As Boolean
Dim issame As Boolean
Dim whole As Long
Dim part As Long
Dim buffer1 As String
Dim buffer2 As String
Dim start As Long
Dim x As Long
Open F1 For Binary As #1
Open F2 For Binary As #2
issame = True
If LOF(1) <> LOF(2) Then
issame = False
Else
whole& = LOF(1) \ 10000 '注释:number of whole 10,000 byte chunks
part& = LOF(1) Mod 10000 ' 注释:remaining bytes at end of file
buffer1$ = String$(10000, 0)
buffer2$ = String$(10000, 0)
start& = 1
For x& = 1 To whole& '注释:this for-next loop will get 10,000
Get #1, start&, buffer1$ ' 注释:byte chunks at a time.
Get #2, start&, buffer2$
If buffer1$ <> buffer2$ Then
issame = False
Exit For
End If
start& = start& + 10000
Next
buffer1$ = String$(part&, 0)
buffer2$ = String$(part&, 0)
Get #1, start&, buffer1$ '注释:get the remaining bytes at the end
Get #2, start&, buffer2$ '注释:get the remaining bytes at the end
If buffer1$ <> buffer2$ Then
issame = False
End If
Close
CompFile = issame
End If
End Function
Private Sub Msg(ByVal sMsg$)
lblMsg.Caption = sMsg
End Sub
Private Function ToHex(ByVal data As Byte) As String
ToHex = Hex(data)
If (data < 16) Then ToHex = "0" & ToHex
End Function
Private Function InitComm(ByVal iPort)
On Error GoTo ErrMsg
If MSComm1.PortOpen Then MSComm1.PortOpen = False
Select Case BaudRateSelCnt
Case 0
MSComm1.Settings = "4800,n,8,1" '可自己修改Baud
Case 1
MSComm1.Settings = "9600,n,8,1" '可自己修改Baud
Case 2
MSComm1.Settings = "19200,n,8,1" '可自己修改Baud
Case 3
MSComm1.Settings = "38400,n,8,1" '可自己修改Baud
Case 4
MSComm1.Settings = "57600,n,8,1" '可自己修改Baud
Case 5
MSComm1.Settings = "115200,n,8,1" '可自己修改Baud
Case 6
MSComm1.Settings = "230400,n,8,1" '可自己修改Baud
Case 7
MSComm1.Settings = "460800,n,8,1" '可自己修改Baud
Case 8
MSComm1.Settings = "921600,n,8,1" '可自己修改Baud
End Select
MSComm1.RThreshold = 1
'MSComm1.InputMode = comInputModeBinary
MSComm1.CommPort = iPort
MSComm1.PortOpen = True
InitComm = True
Exit Function
ErrMsg:
MsgBox Err.Description
InitComm = False
End Function
Private Sub cmdFree_Click()
If MSComm1.PortOpen = False Then
MsgBox "串口并未打开"
MSComm1.PortOpen = True
End If
If MSComm1.PortOpen = True Then
MSComm1.Output = "E"
Msg ("串口已关闭")
End If
End Sub
Private Sub cmdFlashFile_Click()
Dim sFile$, i%
dlgFile.Filter = "*.hex|*.hex|*.bin|*.bin|*.*|*.*"
dlgFile.ShowOpen
sFile = dlgFile.FileName
If dlgFile.FileName = "" Then
Exit Sub
' GoTo theexit
Else
txtFile = sFile
'sFile = App.Path & "\w0.bin"
Open sFile For Binary Access Read As #1
lFile = LOF(1)
ReDim FlashBuf(lFile)
Get #1, , FlashBuf
Close #1
'2006.04.25
' Close
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -