www.pudn.com > YuYinShiBie_VB.zip > voicedll.bas
Attribute VB_Name = "Module1"
'Declarations for own Message handler
Public Const WM_USER = &H400
Public Const GWL_WNDPROC = (-4)
Public PrevWndProc As Long
Public Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Public Declare Function CallWindowProc Lib "user32" Alias "CallWindowProcA" (ByVal lpPrevWndFunc As Long, ByVal hwnd As Long, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
'These are the function defined in our reco.dll
'Init the engine by telling it which window shall receive the notification
Public Declare Function InitSAPI Lib "reco.dll" (ByVal NotifySink As Long)
'If a recoevent occured we can get information about it by calling this function
Public Declare Function ProcessRecoEvent Lib "reco.dll" (ByVal hWindow As Long)
'Training function
Public Declare Function traincmd Lib "reco.dll" (ByVal hWindow As Long)
'Microphone Settings
Public Declare Function miccmd Lib "reco.dll" (ByVal hWindow As Long)
'Recognition Settings
Public Declare Function recocmd Lib "reco.dll" (ByVal hWindow As Long)
'Shutdown the engine by calling this funtion
Public Declare Function CleanupSAPI Lib "reco.dll" ()
'Our self-made Messages:
Public Const WM_RECOEVENT = WM_USER + 190
Public Const WM_RECOGNIZED = WM_USER + 191
Public Function SubWndProc(ByVal hwnd As Long, ByVal fMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
'Something has been recognized call ProcessRecoEVent for details
If fMsg = WM_RECOEVENT Then ProcessRecoEvent (Form1.hwnd)
'The engine recognized a phrase. The wParam of the Message is the Value defined in reco.xml
If fMsg = WM_RECOGNIZED Then
Select Case wParam
Case 1:
Beep
'do something
Case 2:
Beep
'do something else
End Select
End If
SubWndProc = CallWindowProc(PrevWndProc, hwnd, fMsg, wParam, lParam)
End Function