新聞速報

        

2014年2月26日 星期三

VB + 悠遊卡 Dongle API

Private Sub Command_重新開機_Click()
Dim i_ret  As Integer
Dim old   As Long
 
 Dim TMsg As Msg
 
   old = timeGetTime + 1000 * 3  ""Dongle API 對 Dongle 的 TimeOut 為 2 秒,建議收銀機對 Dongle API 的 TimeOut 設成 3 秒
 
   i_ret = OpenCom(0, App.ThreadID)
   
   If i_ret = 0 Then
     
     Call PR_RebootRequest "PR_ReadCardNumberRequest
 
     Do While timeGetTime < old
     
       Debug.Print timeGetTime
       
       "沒收到訊息,會 BLOCK (這時候的 while 迴圈也無效)
       "If GetMessage(TMsg, 0, WM_DONGLE_GETDATA, WM_DONGLE_ERROR) Then
       
       "沒收到訊息,不會 BLOCK
       If PeekMessage(TMsg, 0&, WM_DONGLE_GETDATA, WM_DONGLE_ERROR, PM_NOREMOVE) Then
       
         Debug.Print TMsg.Message
         
         Select Case TMsg.Message
             Case WM_DONGLE_GETDATA
               Debug.Print TMsg.Message & " " & "WM_DONGLE_GETDATA"
               
             Case WM_DONGLE_ERROR
               Debug.Print TMsg.Message & " " & WM_DONGLE_ERROR
         End Select
         
         Exit Do   "能進來 IF 判斷,只有 WM_DONGLE_GETDATA , WM_DONGLE_ERROR
       End If
     Loop
   
   End If
   
   CloseCom
End Sub
 
 
PS:
1.卡機一經啟用且過卡交易後更換電腦IP,將會鎖機。
2.卡機連續 SingOn 失敗六次,將會鎖機。

沒有留言:

張貼留言