SetDeviceCommPwd

Definition

Usage

Set the communication password of the device. The communication password is stored in the device.

Parameter

Device number.

Communication password

Return Value

Return True if it is successful, or return False.

Related Function

SetCommPassword

 

Ejemplo

C#

    /// <summary>
    /// Set the password(device terminal) for communication.
    /// Only PC terminal' password is the same as device terminal's ,you can connect the device.
    /// You can set PC terminal's communication password by the function "SetCommPassword"
    /// </summary>
    /// <param name="CommKey"></param>
    /// <param name="IP"></param>
    /// <param name="Port"></param>
    /// <param name="MachineNumber"></param>
    private void SetDeviceCommPwd(int CommKey = 0, string IP = "10.0.0.44", int Port = 4370, int MachineNumber = 1)
        {
    //Create Standalone SDK class dynamicly.
            zkemkeeper.CZKEMClass axCZKEM1 = new zkemkeeper.CZKEMClass();
            axCZKEM1.Connect_Net(IP, Port);
    int idwErrorCode = 0;
    if (axCZKEM1.SetDeviceCommPwd(MachineNumber, CommKey))
            {
                axCZKEM1.RefreshData(MachineNumber);//the data in the device should be refreshed
                MessageBox.Show("Successfully set commKey! commKey=" + CommKey.ToString(), "Success");
            }
    else
            {
                axCZKEM1.GetLastError(ref idwErrorCode);
                MessageBox.Show("Operation failed, ErrorCode=" + idwErrorCode.ToString(), "Error");
            }
        }

VB

''' <summary>
    ''' Set the password(device terminal) for communication.
    ''' Only PC terminal' password is the same as device terminal's ,you can connect the device.
    ''' You can set PC terminal's communication password by the function "SetCommPassword"
    ''' </summary>
    ''' <param name="CommKey"></param>
    ''' <param name="IP"> Ip of device </param>
    ''' <param name="Port"> Port of Device </param>
    ''' <param name="MachineNumber"> Device Number </param>
    Private Sub SetDeviceCommPwd(Optional CommKey As Integer = 0, Optional IP As String = "10.0.0.44", Optional Port As Integer = 4370, Optional MachineNumber As Integer = 1)
    Dim idwErrorCode As Integer = 0
    'Create Standalone SDK class dynamicly.
    Dim axCZKEM1 As New zkemkeeper.CZKEM
        axCZKEM1.Connect_Net(IP, Convert.ToInt32(Port))
    If axCZKEM1.SetDeviceCommPwd(MachineNumber, CommKey) = True Then
            axCZKEM1.RefreshData(MachineNumber) 'the data in the device should be refreshed
            MsgBox("Successfully set computer's commKey! commKey=" & CommKey, MsgBoxStyle.Information, "Success")
    Else
            axCZKEM1.GetLastError(idwErrorCode)
            MsgBox("Operation failed,ErrorCode=" & idwErrorCode.ToString(), MsgBoxStyle.Exclamation, "Error")
    End If
    End Sub