Set the local computer time to the device time. To set the specified time, see SetDeviceTime2.
Device number.
Return True if it is successful, or return False.
SetDeviceTime2, GetDeviceTime
/// <summary> /// Set the local computer time to the device time. To set the specified time, see SetDeviceTime2. /// </summary> /// <param name="idwYear">Year to set</param> /// <param name="idwMonth">Month to set</param> /// <param name="idwDay">Day to set</param> /// <param name="idwHour">Hour to set</param> /// <param name="idwMinute">Minute to set</param> /// <param name="idwSecond">Second to set</param> /// <param name="IP"> Device IP</param> /// <param name="Port">Port of device</param> /// <param name="MachineNumber">Device number</param> private void SetDeviceTime(int idwYear = 0, int idwMonth = 0, int idwDay = 0, int idwHour = 0, int idwMinute = 0, int idwSecond = 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.SetDeviceTime(MachineNumber)) { axCZKEM1.RefreshData(MachineNumber);//the data in the device should be refreshed MessageBox.Show("Successfully set the time of the machine and the terminal to sync PC!", "Success"); if (axCZKEM1.GetDeviceTime(MachineNumber, ref idwYear, ref idwMonth, ref idwDay, ref idwHour, ref idwMinute, ref idwSecond))//show the time { MessageBox.Show("Successfully set the device Time: " + idwYear.ToString() + "-" + idwMonth.ToString() + "-" + idwDay.ToString() + " " + idwHour.ToString() + ":" + idwMinute.ToString() + ":" + idwSecond.ToString(), "Success"); } } else { axCZKEM1.GetLastError(ref idwErrorCode); MessageBox.Show("Operation failed,ErrorCode=" + idwErrorCode.ToString(), "Error"); } }
Private Sub SetDeviceTime(Optional idwYear As Integer = 0, Optional idwMonth As Integer = 0, Optional idwDay As Integer = 0, Optional idwHour As Integer = 0, Optional idwMinute As Integer = 0, Optional idwSecond 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.SetDeviceTime(MachineNumber) = True Then axCZKEM1.RefreshData(MachineNumber) 'the data in the device should be refreshed MsgBox("Successfully set the time of the machine and the terminal to sync PC!", MsgBoxStyle.Information, "Success") Else axCZKEM1.GetLastError(idwErrorCode) MsgBox("Operation failed,ErrorCode=" & idwErrorCode.ToString(), MsgBoxStyle.Exclamation, "Error") End If End Sub