VERSION 5.00
Begin VB.Form Form1 
   Caption         =   "Form1"
   ClientHeight    =   4590
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   7875
   LinkTopic       =   "Form1"
   ScaleHeight     =   4590
   ScaleWidth      =   7875
   StartUpPosition =   3  'Windows Default
   Begin VB.CommandButton TestBtn 
      Caption         =   "Test"
      Height          =   375
      Left            =   3000
      TabIndex        =   1
      Top             =   4080
      Width           =   1575
   End
   Begin VB.ListBox List1 
      Height          =   3765
      Left            =   120
      TabIndex        =   0
      Top             =   120
      Width           =   7575
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
' ==========================================================================
' Get supper password permission
' (1) the supper password is 8 bytes long, and should not enclose in end-user's software.
'      When the supper password is verified, you have the following permission
'      	a) creat or Delete excutable Files
'     	b) creat or Delete internal Files
'      	c) Format the ROCKEY(card)
'      	d) Reset supper password and Max password attempt 
'     	e) Get remote Update password
' (2) Demo ROCKEY's password is FF FF FF FF FF FF FF FF
' (3) GET_CARD_PRIVILEGE is used to get different permission. the retuned 
'	value in cmddata shhow the status
'     DICPR_NOPASS     0       ' supper password is not verified
'     DICPR_SUPERPASS  4       ' supper password is verified
'     DICPR_REMOTEPASS 8       ' remote update password is verified
' (4) User DIC_Get to get SUPERPASS_STATUS
'     SUPERPASS_STATUS 1     	'supper password is verified
'     SUPERPASS_STATUS 0     	'supper password is not verified
'     REMOTEPASS_STATUS is the same
' (5) when set supper password, you also need to set the max. attempt
' ==========================================================================

Private Sub TestBtn_Click()
Dim errcode, num, hic, i As Long
Dim cmddata(0 To 255) As Byte ' command buffer
Dim buffer(0 To 255) As Byte ' user buffer
Dim curline As Integer

curline = 0

num = DIC_Find()
For i = 0 To num - 1
    hic = DIC_Open(i, 0&)
    If (hic >= 0) Then
        Exit For
    End If
Next i
If (i = num) Then
    Exit Sub
End If

errcode = DIC_Command(hic, GET_CARD_PRIVILEGE, cmddata(0))
If (DIC_Get(cmddata(0), SUPERPASS_STATUS, BY_VALUE, 0&) <> 0) Then
    List1.List(curline) = "supper password is verified"
Else
    List1.List(curline) = "supper password is not verified"
End If
curline = curline + 1

' Demo ROCKEY's password is FF FF FF FF FF FF FF FF
For i = 0 To 7
    cmddata(i) = 255
Next i
errcode = DIC_Command(hic, CHECK_SUPER_PASS, cmddata(0))

' Read SUPERPASS_STATUS
errcode = DIC_Command(hic, GET_CARD_PRIVILEGE, cmddata(0))
If (DIC_Get(cmddata(0), SUPERPASS_STATUS, BY_VALUE, 0&) <> 0) Then
    List1.List(curline) = "supper password is verified"
Else
    List1.List(curline) = "supper password is not verified"
End If
curline = curline + 1

' Reset supper password
' new password in buffer(0 1 2 3 4 5 6 7)
' set max. attempt (10) in p3 of DIC_Set
For i = 0 To 7
    buffer(i) = i
Next i
errcode = DIC_Set(cmddata(0), SUPERPASS_DATA, BY_ARRAY, 10, buffer(0))
errcode = DIC_Command(hic, SET_SUPER_PASS, cmddata(0))

' canel the supper password permission
errcode = DIC_Close(hic)
errcode = DIC_Open(hic, 0&)

' verify new supper password
For i = 0 To 7
    cmddata(i) = i
Next i
errcode = DIC_Command(hic, CHECK_SUPER_PASS, cmddata(0))

' read SUPERPASS_STATUS
errcode = DIC_Command(hic, GET_CARD_PRIVILEGE, cmddata(0))
If (DIC_Get(cmddata(0), SUPERPASS_STATUS, BY_VALUE, 0&) <> 0) Then
    List1.List(curline) = "supper password is verified"
Else
    List1.List(curline) = "supper password is not verified"
End If
curline = curline + 1


' reset password to FF FF FF FF FF FF FF FF 
For i = 0 To 7
    buffer(i) = 255
Next i
errcode = DIC_Set(cmddata(0), SUPERPASS_DATA, BY_ARRAY, 10, buffer(0))
errcode = DIC_Command(hic, SET_SUPER_PASS, cmddata(0))

errcode = DIC_Close(hic)
End Sub

