Attribute VB_Name = "Module3"
Option Explicit

Dim comp_status As Integer
Dim mySB As SecureBlock

Sub Main()

    Dim FLG As String
    Dim k, i, j As Integer
    
    ' First clear out the SB contents to a known state
    ClearSB mySB
    
    ' setup the contents of the SB buffer
    mySB.SNP = 0
    mySB.PIN = &HC358FC80       'Hex value of PIN 3277388928
    
    mySB.FUNC = 1
    
    ' copy the path of the executing program to the SB buffer
    mySB.SOURCE = App.Path & "CAT.EXE" & Chr$(0)
    
    ' turn on the hourglass cursor
    Screen.MousePointer = 11
     
    ' check the authorization
    comp_status = EVCHK32(mySB)
    
    ' restore the original cursor
    Screen.MousePointer = 0
    
    frmMain.Show
    
    ' verify the success of the EVCHK32 function
    If comp_status <> 0 Then
          ' show the user the error
        MsgBox "EVCHK32.DLL Error " + Str$(comp_status) + "!", 16, Error
    ElseIf mySB.STAT1 <> 0 Then
        frmMain.picText.Print " Return Code: ", , Hex$(mySB.STAT1); "-"; Hex$(mySB.STAT2); "-"; Hex$(mySB.STAT3)
    Else
        frmMain.picText.Print " Function Code:", , mySB.FUNC
        frmMain.picText.Print " DriveID:", , mySB.DRV; ":"
        frmMain.picText.Print " Product:", , mySB.PROD
        frmMain.picText.Print " Product Serial #:", mySB.SNP
        frmMain.picText.Print " Authorization Version:", , mySB.AVERS
        
        If mySB.ECL = &HFFFF Then
            frmMain.picText.Print " Exec-Count Limit:", "Unlimited"
        Else
            frmMain.picText.Print " Current Exec-Count:", mySB.ECL
        End If
        
        If mySB.EDL = &HFFFF Then
            frmMain.picText.Print " Expire-Days Limit:", "Unlimited"
        Else
            frmMain.picText.Print " Current Days Left:", mySB.EDL
            frmMain.picText.Print " Expire Date:", , mySB.ED
        End If
        
        If mySB.NUL = &HFFFF Then
            frmMain.picText.Print " Net-Users Limit:", "Unlimited"
        Else
           frmMain.picText.Print " Net-Users Count:", mySB.NUC
           frmMain.picText.Print " Net-Users Limit:", mySB.NUL
        End If
        
        If mySB.PTYPE = "P" Then
           frmMain.picText.Print " Install Count:", mySB.ICR
        End If

       '  Print list of Access Flags
        FLG$ = ""
        k = 0
        frmMain.picText.Print " Access Flags Set: ",
        For i = 0 To 7
            FLG$ = Mid$(mySB.ACCFLG, i + 1, 1)
        For j = 1 To 8
            If j = 1 Then
                If Asc(FLG$) And 1 Then
                    frmMain.picText.Print ((i * 8) + j); " ";
                    k = k + 1
                End If
            End If
            If j = 2 Then
                If Asc(FLG$) And 2 Then
                    frmMain.picText.Print ((i * 8) + j); " ";
                    k = k + 1
                End If
            End If
            If j = 3 Then
                If Asc(FLG$) And 4 Then
                    frmMain.picText.Print ((i * 8) + j); " ";
                    k = k + 1
                End If
            End If
            If j = 4 Then
                If Asc(FLG$) And 8 Then
                    frmMain.picText.Print ((i * 8) + j); " ";
                    k = k + 1
                End If
            End If
            If j = 5 Then
                If Asc(FLG$) And 16 Then
                    frmMain.picText.Print ((i * 8) + j); " ";
                    k = k + 1
                End If
            End If
            If j = 6 Then
                If Asc(FLG$) And 32 Then
                    frmMain.picText.Print ((i * 8) + j); " ";
                    k = k + 1
                End If
            End If
            If j = 7 Then
                If Asc(FLG$) And 64 Then
                    frmMain.picText.Print ((i * 8) + j); " ";
                    k = k + 1
                End If
            End If
            If j = 8 Then
                If Asc(FLG$) And 128 Then
                    frmMain.picText.Print ((i * 8) + j); " ";
                    k = k + 1
                End If
            End If
        Next j
    Next i
    If k = 0 Then
        frmMain.picText.Print "NONE"
    End If
        
    '  Print Registration Info
    If mySB.RTYPE = "N" Then
        frmMain.picText.Print " Registered to Name: ", mySB.RNAME
        frmMain.picText.Print " Registered to Company: ", mySB.RCOMP
        frmMain.picText.Print " Registered Location: ", mySB.RLOC
    End If
        
    '  Print Current Date
    frmMain.picText.Print " Current Date: ", , mySB.CDATE
        
    '  Print Secure String
    frmMain.picText.Print " Secure String: "
    frmMain.picText.Print mySB.SECSTR
End If
        
        End Sub
        
