OVH Cloud OVH Cloud

Passage d'une appli VB 5 à vbs pour html

1 réponse
Avatar
aXi
Je souhaiterai passer ce code en VBScript :
--------------------------------------------------------
Option Explicit

Private Declare Function tapiRequestMakeCall&=20
Lib "TAPI32.DLL" (ByVal DestAddress$, ByVal AppName$,=20
ByVal CalledParty$, ByVal Comment$)
Private Const TAPIERR_NOREQUESTRECIPIENT =3D -2&
Private Const TAPIERR_REQUESTQUEUEFULL =3D -3&
Private Const TAPIERR_INVALDESTADDRESS =3D -4&

Private Sub Form_Load()
EnableDial
End Sub

Private Sub txtNumber_Change()
EnableDial
End Sub

Private Sub cmdDial_Click()
Dim buff As String
Dim nResult As Long

'Invoke tapiRequestMakeCall. If tapiRequestMakeCall=20
returns 0, the
'request has been accepted. It is up to the call=20
manager application
'to do any further work. The second-to-last argument=20
should be
'changed to be the name of the person you are dialing.
nResult =3D tapiRequestMakeCall&(Trim$(txtNumber), CStr
(Caption), "Test", "Comment")
'Display message if error
If nResult <> 0 Then
buff =3D "Error dialing number : "
Select Case nResult
Case TAPIERR_NOREQUESTRECIPIENT
buff =3D buff & "No Windows Telephony=20
dialing application is running and none could be started."
Case TAPIERR_REQUESTQUEUEFULL
buff =3D buff & "The queue of pending=20
Windows Telephony dialing requests is full."
Case TAPIERR_INVALDESTADDRESS
buff =3D buff & "The phone number is not=20
valid."
Case Else
buff =3D buff & "Unknown error."
End Select
MsgBox buff
End If
End Sub

Private Sub cmdExit_Click()
Unload Me
End Sub

Private Sub EnableDial()
cmdDial.Enabled =3D Len(Trim$(txtNumber)) > 0
End Sub
--------------------------------------------------------

J'aurai bien fait simplement =E7a :

Option Explicit
Private Declare Function tapiRequestMakeCall&=20
Lib "TAPI32.DLL" (ByVal DestAddress$, ByVal AppName$,=20
ByVal CalledParty$, ByVal Comment$)

msgbox "test"
tapiRequestMakeCall&("192.168.0.108", "VBScript=20
autodial", "Nom du destinataire", "Appel r=E9alis=E9 d'un=20
script VB")
WScript.Quit

Mais =E7a ne fonctionne pas...

1 réponse

Avatar
ng
Salut,

Pas d'accès au APIs Windows ni DLLs classique en VBS, seulement du COM
(CreateObject()). Il faudra wrapper ta fonction dans une DLL COM ou procéder
autrement.

--
Nicolas G.
FAQ VB : http://faq.vb.free.fr
API Guide : http://www.allapi.net
Google Groups : http://groups.google.fr/
MZ-Tools : http://www.mztools.com/
http://apisvb.europe.webmatrixhosting.net/




Je souhaiterai passer ce code en VBScript :
--------------------------------------------------------
Option Explicit

Private Declare Function tapiRequestMakeCall&
Lib "TAPI32.DLL" (ByVal DestAddress$, ByVal AppName$,
ByVal CalledParty$, ByVal Comment$)
Private Const TAPIERR_NOREQUESTRECIPIENT = -2&
Private Const TAPIERR_REQUESTQUEUEFULL = -3&
Private Const TAPIERR_INVALDESTADDRESS = -4&

Private Sub Form_Load()
EnableDial
End Sub

Private Sub txtNumber_Change()
EnableDial
End Sub

Private Sub cmdDial_Click()
Dim buff As String
Dim nResult As Long

'Invoke tapiRequestMakeCall. If tapiRequestMakeCall
returns 0, the
'request has been accepted. It is up to the call
manager application
'to do any further work. The second-to-last argument
should be
'changed to be the name of the person you are dialing.
nResult = tapiRequestMakeCall&(Trim$(txtNumber), CStr
(Caption), "Test", "Comment")
'Display message if error
If nResult <> 0 Then
buff = "Error dialing number : "
Select Case nResult
Case TAPIERR_NOREQUESTRECIPIENT
buff = buff & "No Windows Telephony
dialing application is running and none could be started."
Case TAPIERR_REQUESTQUEUEFULL
buff = buff & "The queue of pending
Windows Telephony dialing requests is full."
Case TAPIERR_INVALDESTADDRESS
buff = buff & "The phone number is not
valid."
Case Else
buff = buff & "Unknown error."
End Select
MsgBox buff
End If
End Sub

Private Sub cmdExit_Click()
Unload Me
End Sub

Private Sub EnableDial()
cmdDial.Enabled = Len(Trim$(txtNumber)) > 0
End Sub
--------------------------------------------------------

J'aurai bien fait simplement ça :

Option Explicit
Private Declare Function tapiRequestMakeCall&
Lib "TAPI32.DLL" (ByVal DestAddress$, ByVal AppName$,
ByVal CalledParty$, ByVal Comment$)

msgbox "test"
tapiRequestMakeCall&("192.168.0.108", "VBScript
autodial", "Nom du destinataire", "Appel réalisé d'un
script VB")
WScript.Quit

Mais ça ne fonctionne pas...