Страница: 1 |
|
Вопрос: Дозвон и всякое такое...
|
Добавлено: 07.10.04 16:14
|
|
Автор вопроса: Serik | ICQ: 206428963
|
Как звонить по телефону введённому в textbox, а не в списке подключений к Инету? Второй случай ясен, а первый...
Ответить
|
Номер ответа: 9 Автор ответа: Novichek
Вопросов: 19 Ответов: 60
|
Профиль | | #9
|
Добавлено: 09.10.04 19:40
|
Это в модуль:
Public Declare Function RasDial _
Lib "rasapi32.dll" Alias "RasDialA" _
 lpRasDialExtensions As Any, _
ByVal lpszPhonebook As String, _
lpRasDialParams As Any, _
ByVal dwNotifierType As Long, _
ByVal hwndNotifier As Long, _
lphRasConn As Long) _
As Long
Public Declare Function RasGetEntryDialParams _
Lib "rasapi32.dll" Alias "RasGetEntryDialParamsA" _
 ByVal lpszPhonebook As String, _
lpRasDialParams As Any, _
blnPasswordRetrieved As Long) As Long
Public Declare Function RasSetEntryDialParams _
Lib "rasapi32.dll" Alias "RasSetEntryDialParamsA" _
 ByVal lpszPhonebook As String, _
lpRasDialParams As Any, _
ByVal blnRemovePassword As Long) As Long
Public Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" _
 Destination As Any, Source As Any, ByVal Length As Long)
Declare Function RasHangUp _
Lib "rasapi32.dll" Alias "RasHangUpA" _
 ByVal hRasConn As Long) As Long
Public Type VBRasDialParams
EntryName As String
PhoneNumber As String
CallbackNumber As String
UserName As String
Password As String
 omain As String
SubEntryIndex As Long
RasDialFunc2CallbackId As Long
End Type
Public Enum RASCONNSTATE
RASCS_OpenPort = &H0
RASCS_PortOpened = &H1
RASCS_ConnectDevice = &H2
RASCS_DeviceConnected = &H3
RASCS_AllDevicesConnected = &H4
RASCS_Authenticate = &H5
RASCS_AuthNotify = &H6
RASCS_AuthRetry = &H7
RASCS_AuthCallback = &H8
RASCS_AuthChangePassword = &H9
RASCS_AuthProject = &HA
RASCS_AuthLinkSpeed = &HB
RASCS_AuthAck = &HC
RASCS_ReAuthenticate = &HD
RASCS_Authenticated = &HE
RASCS_PrepareForCallback = &HF
RASCS_WaitForModemReset = &H10
RASCS_WaitForCallback = &H11
RASCS_Projected = &H12
RASCS_StartAuthentication = &H13
RASCS_CallbackComplete = &H14
RASCS_LogonNetwork = &H15
RASCS_SubEntryConnected = &H16
RASCS_SubEntryDisconnected = &H17
RASCS_Interactive = &H1000
RASCS_RetryAuthentication = &H1001
RASCS_CallbackSetByCaller = &H1002
RASCS_PasswordExpired = &H1003
RASCS_InvokeEapUI = &H1004
RASCS_Connected = &H2000
RASCS_Disconnected = &H2001
End Enum
Private lngHandle As Long, OldWndProc As Long
'for status
Private lngStat As Long, strStat
Declare Function RasGetConnectStatus _
Lib "rasapi32.dll" Alias "RasGetConnectStatusA" _
 ByVal hRasConn As Long, _
lpRasConnStatus As Any) As Long
Type VBRASCONNSTATUS
lRasConnState As RASCONNSTATE
dwError As Long
sDeviceType As String
sDeviceName As String
sNTPhoneNumber As String
End Type
'end for status
Function VBRasDialParamsToBytes( _
udtVBRasDialParamsIN As VBRasDialParams, _
bytesOut() As Byte) As Boolean
 im rtn As Long
 im blnPsswrd As Long
 im b() As Byte
 im bLens As Variant
 im dwSize As Long, i As Long
 im iPos As Long, lngLen As Long
bLens = Array(1060&, 1052&, 816&
For i = 0 To 2
dwSize = bLens(i)
ReDim b(dwSize - 1)
CopyMemory b(0), dwSize, 4
 oEvents
rtn = RasGetEntryDialParams(vbNullString, b(0), blnPsswrd)
If rtn = 623& Then Exit For
Next i
If rtn <> 623& Then Exit Function
On Error GoTo badBytes
ReDim bytesOut(dwSize - 1)
CopyMemory bytesOut(0), dwSize, 4
If dwSize = 816& Then
lngLen = 21&
ElseIf dwSize = 1060& Or dwSize = 1052& Then
lngLen = 257&
Else
'hren znaet cho za razmer
Exit Function
End If
iPos = 4
With udtVBRasDialParamsIN
CopyStringToByte bytesOut(iPos), .EntryName, lngLen
iPos = iPos + lngLen: lngLen = 129
CopyStringToByte bytesOut(iPos), .PhoneNumber, lngLen
iPos = iPos + lngLen: lngLen = 129
CopyStringToByte bytesOut(iPos), .CallbackNumber, lngLen
iPos = iPos + lngLen: lngLen = 257
CopyStringToByte bytesOut(iPos), .UserName, lngLen
iPos = iPos + lngLen: lngLen = 257
CopyStringToByte bytesOut(iPos), .Password, lngLen
iPos = iPos + lngLen: lngLen = 16
CopyStringToByte bytesOut(iPos), .Domain, lngLen
If dwSize > 1052& Then
CopyMemory bytesOut(1052), .SubEntryIndex, 4&
CopyMemory bytesOut(1056), .RasDialFunc2CallbackId, 4&
End If
End With
VBRasDialParamsToBytes = True
Exit Function
badBytes:
VBRasDialParamsToBytes = False
End Function
Sub CopyStringToByte(bPos As Byte, _
strToCopy As String, lngMaxLen As Long)
 im lngLen As Long
lngLen = Len(strToCopy)
If lngLen = 0 Then
Exit Sub
ElseIf lngLen > lngMaxLen Then
lngLen = lngMaxLen
End If
CopyMemory bPos, ByVal strToCopy, lngLen
End Sub
'Status
Function VBRasGetConnectStatus _
 hRasConn As Long, _
udtVBRasConnStatus As VBRASCONNSTATUS) As Long
 im i As Long, dwSize As Long
 im aVarLens As Variant
 im b() As Byte
aVarLens = Array(288&, 160&, 64&
For i = 0 To 2
dwSize = aVarLens(i)
ReDim b(dwSize - 1)
CopyMemory b(0), dwSize, 4
rtn = RasGetConnectStatus(hRasConn, b(0))
If rtn <> 632 Then Exit For
Next i
VBRasGetConnectStatus = rtn
If rtn <> 0 Then Exit Function
With udtVBRasConnStatus
CopyMemory .lRasConnState, b(4), 4
CopyMemory .dwError, b(8), 4
CopyByteToTrimmedString .sDeviceType, b(12), 17&
If dwSize = 64& Then
CopyByteToTrimmedString .sDeviceName, b(29), 33&
ElseIf dwSize = 160& Then
CopyByteToTrimmedString .sDeviceName, b(29), 129&
Else
CopyByteToTrimmedString .sDeviceName, b(29), 129&
CopyByteToTrimmedString .sNTPhoneNumber, b(158), 129&
End If
End With
lngStat = udtVBRasConnStatus.lRasConnState
Select Case lngStat
Case Is = RASCS_OpenPort: strStat = "Открытие порта..."
Case Is = RASCS_PortOpened: strStat = "Порт открыт..."
Case Is = RASCS_ConnectDevice: strStat = "Идёт установка связи..."
Case Is = RASCS_DeviceConnected: strStat = "Связь установлена..."
Case Is = RASCS_AllDevicesConnected: strStat = "Все устройства успешно подключились..."
Case Is = RASCS_StartAuthentication: strStat = "Аутентификация пользователя началась или повторяется..."
Case Is = RASCS_Authenticate: strStat = "Идёт атентификация..."
Case Is = RASCS_AuthNotify: strStat = "Аутентификация прошла..."
Case Is = RASCS_AuthRetry: strStat = "Клиент потребовал аутентификацию с новым именем/паролем..."
Case Is = RASCS_AuthCallback: strStat = "Сервер потребовал номер отзыва..."
Case Is = RASCS_AuthChangePassword: strStat = "Клиент просил изменить пароль..."
Case Is = RASCS_AuthProject: strStat = "Стадия проектирования начата..."
Case Is = RASCS_AuthLinkSpeed: strStat = "Идет вычисление скорости соединения..."
Case Is = RASCS_AuthAck: strStat = "Опознавательный запрос признан..."
Case Is = RASCS_ReAuthenticate: strStat = "Переопознавание (после отзыва) начинается..."
Case Is = RASCS_Authenticated: strStat = "Аутентификация прошла успешно..."
Case Is = RASCS_PrepareForCallback: strStat = "Подкотовка к разъединению..."
Case Is = RASCS_WaitForCallback: strStat = "Ждём запроса от сервера..."
Case Is = RASCS_CallbackComplete: strStat = "Клиент возобновляет аутентификацию..."
Case Is = RASCS_WaitForModemReset: strStat = "Задержа для модема перед подкотовкой к отзыву..."
Case Is = RASCS_Projected: strStat = "Результаты проектирования доступны..."
Case Is = RASCS_LogonNetwork: strStat = "Вход в сеть..."
Case Is = RASCS_Interactive: strStat = "Определение поддержки RASPHONE.EXE..."
Case Is = RASCS_RetryAuthentication: strStat = "Повторное определение поддержки RASPHONE.EXE..."
Case Is = RASCS_CallbackSetByCaller: strStat = "Отзыв поддержки RASPHONE.EXE..."
Case Is = RASCS_PasswordExpired: strStat = "Изменение пароля поддержки RASPHONE.EXE..."
Case Is = RASCS_Connected: strStat = "Соединение..."
Case Is = RASCS_Disconnected: strStat = "Разъединение..."
Case Is = RASCS_SubEntryConnected: strStat = "Подвход был соединён во время дозвона"
Case Is = RASCS_SubEntryDisconnected: strStat = "Подвход был разъединён во время дозвона"
End Select
frmRas.Label1.Caption = strStat
If lngStat = RASCS_Disconnected Then RasHangUp (hRasConn)
End Function
Sub CopyByteToTrimmedString(strToCopyTo As String, _
bPos As Byte, lngMaxLen As Long)
 im strTemp As String, lngLen As Long
strTemp = String(lngMaxLen + 1, 0)
CopyMemory ByVal strTemp, bPos, lngMaxLen
lngLen = InStr(strTemp, Chr$(0)) - 1
strToCopyTo = Left$(strTemp, lngLen)
End Sub
Это в форму:
Dim lngHConn As Long
Dim prevStat As RASSTATS2000
Public Function DING(NameSoed As String, UserName As String, Pass As String, NumPhone As String, lngHConn As Long) As Boolean
 im rtn As Long
 im b() As Byte
 im myDialParams As VBRasDialParams
 im strPhonebook As String
 im myConnStatus As VBRASCONNSTATUS
On Local Error Resume Next
With myDialParams
.EntryName = NameSoed
.UserName = UserName
.Password = Pass
If chkPuls.Value Then
.PhoneNumber = "P" & NumPhone' impuls
Else
.PhoneNumber = "T" & NumPhone' ton
End If
End With
Call RasHangUp(lngHConn)
If Not DING = 0 Then Exit Function
rtn = VBRasDialParamsToBytes(myDialParams, b)
If Not DING = 0 Then Exit Function
rtn = RasDial(ByVal 0&, strPhonebook, b(0), &HFFFFFFFF, Me.hwnd, lngHConn)
Do
rtn = VBRasGetConnectStatus(lngHConn, myConnStatus)
DoEvents
Loop While rtn = 0
If rtn Then Label1.Caption = "Будем звонить или чё?"
End Function
И вызывай:
DING "имя соединения", "логин", "пароль", "телефон", lngHConn
Ответить
|
Страница: 1 |
Поиск по форуму