📄 ictest.bas
字号:
Attribute VB_Name = "ICTEST1"
Global icdev As Long
'useful function.
Declare Function IC_InitComm Lib "lkic32.dll" (ByVal Port%) As Long
Declare Function IC_ExitComm% Lib "lkic32.dll" (ByVal icdev As Long)
Declare Function IC_Down% Lib "lkic32.dll" (ByVal icdev As Long)
Declare Function IC_InitType% Lib "lkic32.dll" (ByVal icdev As Long, ByVal TypeNo%)
Declare Function IC_Status% Lib "lkic32.dll" (ByVal icdev As Long)
Declare Function IC_Read% Lib "lkic32.dll" (ByVal icdev As Long, ByVal offset%, ByVal l%, ByVal dataBuffer$)
Declare Function IC_Read_Hex% Lib "lkic32.dll" (ByVal icdev As Long, ByVal offset%, ByVal l%, ByVal dataBuffer$)
Declare Function IC_Write% Lib "lkic32.dll" (ByVal icdev As Long, ByVal offset%, ByVal length%, ByVal dataBuffer$)
Declare Function IC_Write_Hex% Lib "lkic32.dll" (ByVal icdev As Long, ByVal offset%, ByVal length%, ByVal dataBuffer$)
'4442
Declare Function IC_ReadProtection% Lib "lkic32.dll" (ByVal icdev As Long, ByVal offset%, ByVal l%, ByVal ProtBuffer$)
Declare Function IC_WriteProtection% Lib "lkic32.dll" (ByVal icdev As Long, ByVal offset%, ByVal l%, ByVal ProtBuffer$)
Declare Function IC_ReadCount_SLE4442% Lib "lkic32.dll" (ByVal icdev As Long)
Declare Function IC_CheckPass_SLE4442hex% Lib "lkic32.dll" (ByVal icdev As Long, ByVal password$)
Declare Function IC_ChangePass_SLE4442hex% Lib "lkic32.dll" (ByVal icdev As Long, ByVal password$)
'4428
Declare Function IC_ReadWithProtection% Lib "lkic32.dll" (ByVal icdev As Long, ByVal offset%, ByVal l%, ByVal ProtBuffer$)
Declare Function IC_WriteWithProtection% Lib "lkic32.dll" (ByVal icdev As Long, ByVal offset%, ByVal l%, ByVal ProtBuffer$)
Declare Function IC_ReadCount_SLE4428% Lib "lkic32.dll" (ByVal icdev As Long)
Declare Function IC_CheckPass_SLE4428% Lib "lkic32.dll" (ByVal icdev As Long, ByVal password$)
Declare Function IC_CheckPass_SLE4428hex% Lib "lkic32.dll" (ByVal icdev As Long, ByVal password$)
Declare Function IC_ChangePass_SLE4428hex% Lib "lkic32.dll" (ByVal icdev As Long, ByVal password$)
'ATMEL102
Declare Function IC_CheckPass_102hex% Lib "lkic32.dll" (ByVal icdev As Long, ByVal password$)
Declare Function IC_ChangePass_102hex% Lib "lkic32.dll" (ByVal icdev As Long, ByVal password$)
Declare Function IC_ReadCount_102% Lib "lkic32.dll" (ByVal icdev As Long)
Declare Function IC_CheckAZPass_102% Lib "lkic32.dll" (ByVal icdev As Long, ByVal Zone%, ByVal password$)
Declare Function IC_ChangeAZPass_102% Lib "lkic32.dll" (ByVal icdev As Long, ByVal Zone%, ByVal password$)
Declare Function IC_Erase_102% Lib "lkic32.dll" (ByVal icdev As Long, ByVal offset%, ByVal l%)
Declare Function IC_Fuse_102% Lib "lkic32.dll" (ByVal icdev As Long)
Declare Function IC_EWrite_102% Lib "lkic32.dll" (ByVal icdev As Long, ByVal offset%, ByVal length%, ByVal dataBuffer$)
Declare Function IC_EWrite_102Hex% Lib "lkic32.dll" (ByVal icdev As Long, ByVal offset%, ByVal length%, ByVal dataBuffer$)
'ATMEL1604
Declare Function IC_CheckPass_1604hex% Lib "lkic32.dll" (ByVal icdev As Long, ByVal Area%, ByVal password$)
Declare Function IC_ChangePass_1604hex% Lib "lkic32.dll" (ByVal icdev As Long, ByVal Area%, ByVal password$)
Declare Function IC_ReadCount_1604% Lib "lkic32.dll" (ByVal icdev As Long, ByVal Area As Integer)
Declare Function IC_Fuse_1604% Lib "lkic32.dll" (ByVal icdev As Long)
'45D041
Declare Function IC_DriectRead% Lib "lkic32.dll" (ByVal icdev As Long, ByVal page%, ByVal offset%, ByVal bytes%, ByVal buff$)
Declare Function IC_DriectWrite% Lib "lkic32.dll" (ByVal icdev As Long, ByVal page%, ByVal offset%, ByVal bytes%, ByVal buff$)
Declare Function IC_WriteByBuffer% Lib "lkic32.dll" (ByVal icdev As Long, ByVal page%, ByVal offset%, ByVal bytes%, ByVal buff$)
Declare Function IC_DriectRead_Hex% Lib "lkic32.dll" (ByVal icdev As Long, ByVal page%, ByVal offset%, ByVal bytes%, ByVal buff$)
Declare Function IC_DriectWrite_Hex% Lib "lkic32.dll" (ByVal icdev As Long, ByVal page%, ByVal offset%, ByVal bytes%, ByVal buff$)
Declare Function IC_WriteByBuffer_Hex% Lib "lkic32.dll" (ByVal icdev As Long, ByVal page%, ByVal offset%, ByVal bytes%, ByVal buff$)
'
Global Const LK_OK = &H0 '操作正确
Global Const LK_COMM_ERR = -&H82 '通讯错误
Global Const LK_PASS_ERR = -&H83 '密码效验错
Global Const LK_NO_ICC = -&H86 '没有插卡
Global Const LK_FORMAT_ERR = -&H1 '异常错误
Sub icerr(ByVal errno As Integer)
Select Case errno
Case LK_OK: MsgBox "操作正确"
Case LK_COMM_ERR: MsgBox "通讯错误"
Case LK_PASS_ERR: MsgBox "密码效验错"
Case LK_NO_ICC: MsgBox "没有插卡"
Case LK_FORMAT_ERR: MsgBox "异常错误"
Case Else: MsgBox ("错误号:" + Str$(errno))
End Select
End Sub
Sub Main()
Dim com%, cardtype%
Dim pass$
Dim buffer As String * 512
com% = 0 '串口1
cardtype% = 4
icdev = IC_InitComm(com%)
If icdev < 0 Then
st = IC_ExitComm(com%)
End
End If
st = IC_InitType(icdev, cardtype%)
st = IC_ReadCount_SLE4428(icdev)
MsgBox "Error count: " + Str(st), 0, "LKIC"
pass$ = "67c6"
' pass = Chr(&H67) + Chr(&HC6)
st = IC_CheckPass_SLE4428hex(icdev, pass$)
MsgBox "Check pass: " + Str(st), 0, "LKIC"
' pass$ = "67C6"
' st = IC_ChangePass_SLE4428hex(icdev, pass$)
' MsgBox "Change pass: " + Str(st), 0, "LKIC"
prot_len = 3
buffer = Space(2 * prot_len)
st = IC_ReadWithProtection(icdev, 0, prot_len, buffer)
If st < 0 Then
MsgBox Str(st), 0, "LKIC"
st = IC_ExitComm(icdev)
End
End If
For i = 1 To prot_len
If Mid$(buffer, prot_len + i, 1) = Chr(0) Then
MsgBox Str(prot_offset + i) + "已保护", 0, "LKIC"
Else
MsgBox Str(prot_offset + i) + "未保护", 0, "LKIC"
End If
Next i
prot_offset = 255
prot_len = 1
buff = "L"
' st = IC_WriteWithProtection(icdev,prot_offset,prot_len,buffer)
MsgBox Str(st), 0, "LKIC"
buff = "qwer"
st = IC_Write(icdev, 32, 4, buff)
MsgBox Str(st), 0, "LKIC"
st = IC_ExitComm(icdev)
End
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -