发表于:2001/8/18 7:44:00
#0楼
只用了tapiRequestMakeCall函数的简单程序,可以了解一下TAPI与直接用AT指令控制MODEM的区别。建立窗口,放置Command1,直接将代码粘贴到窗口CODE中就可以了。
Option Explicit
Private Declare Function tapiRequestMakeCall Lib "tapi32.dll" _
(ByVal stNumber As String, ByVal stDummy1 As String, _
ByVal stDummy2 As String, ByVal stDummy3 As String) As Long
Private Const ID_CANCEL = 2
Private Const MB_OKCANCEL = 1
Private Const MB_ICONSTOP = 16, MB_ICONINFORMATION = 64
Function DialNumber(PhoneNumber)
Dim Msg As String, MsgBoxType As Integer, MsgBoxTitle As String
Dim RetVal As Long
' Ask the user to pick up the phone.
Msg = "Please pickup the phone and click OK to dial " _
& PhoneNumber
MsgBoxType = MB_ICONINFORMATION + MB_OKCANCEL
MsgBoxTitle = "Dial Number"
If MsgBox(Msg, MsgBoxType, MsgBoxTitle) = ID_CANCEL Then
Exit Function
End If
' Send the telephone number to the modem.
RetVal = tapiRequestMakeCall(PhoneNumber, "", "", "")
If RetVal < 0 Then
Msg = "Unable to dial number " & PhoneNumber
GoTo Err_DialNumber
End If
Exit Function
Err_DialNumber: 'This is not an On Error routine.
Msg = Msg & vbCr & vbCr & _
"Make sure no other devices are using the Com port"
MsgBoxType = MB_ICONSTOP
MsgBoxTitle = "Dial Number Error"
MsgBox Msg, MsgBoxType, MsgBoxTitle
End Function
Private Sub Command1_Click()
Call DialNumber("0755")
End Sub
Option Explicit
Private Declare Function tapiRequestMakeCall Lib "tapi32.dll" _
(ByVal stNumber As String, ByVal stDummy1 As String, _
ByVal stDummy2 As String, ByVal stDummy3 As String) As Long
Private Const ID_CANCEL = 2
Private Const MB_OKCANCEL = 1
Private Const MB_ICONSTOP = 16, MB_ICONINFORMATION = 64
Function DialNumber(PhoneNumber)
Dim Msg As String, MsgBoxType As Integer, MsgBoxTitle As String
Dim RetVal As Long
' Ask the user to pick up the phone.
Msg = "Please pickup the phone and click OK to dial " _
& PhoneNumber
MsgBoxType = MB_ICONINFORMATION + MB_OKCANCEL
MsgBoxTitle = "Dial Number"
If MsgBox(Msg, MsgBoxType, MsgBoxTitle) = ID_CANCEL Then
Exit Function
End If
' Send the telephone number to the modem.
RetVal = tapiRequestMakeCall(PhoneNumber, "", "", "")
If RetVal < 0 Then
Msg = "Unable to dial number " & PhoneNumber
GoTo Err_DialNumber
End If
Exit Function
Err_DialNumber: 'This is not an On Error routine.
Msg = Msg & vbCr & vbCr & _
"Make sure no other devices are using the Com port"
MsgBoxType = MB_ICONSTOP
MsgBoxTitle = "Dial Number Error"
MsgBox Msg, MsgBoxType, MsgBoxTitle
End Function
Private Sub Command1_Click()
Call DialNumber("0755")
End Sub