Forums Últimos mensajes - Powered by IBM
 

Api RASDIAL para vb.net

03/10/2005 - 18:14 por infojerez | Informe spam
Hola.

Estoy intentando modificar la API rasdial para vb.net que tengo para vb6
pero no logro hacerla funcionar, ¿alguien la tiene para vb.net?

Gracias y saludos

p.d.
El siguiente codigo me funciona perfectamente para vb6

Private Type RASDIALPARAMS
dwSize As Long
szEntryName As String * 257
szPhoneNumber As String * 129
szCallbackNumber As String * 129
szUserName As String * 257
szPassword As String * 257
szDomain As String * 16
filler As String * 16
End Type
Private Type RASCONNSTATUS
dwSize As Long
Estado As Integer
filler As String * 160
End Type
Private Declare Sub Sleep Lib "kernel32.dll" (ByVal miliseg As Long)
Private Declare Sub strcpyn Lib "kernel32.dll" Alias "lstrcpynA" (ByVal
A As String, ByVal de As String, ByVal n As Long)
Private Declare Function strlen Lib "kernel32.dll" Alias "lstrlenA"
(ByVal texto As String) As Long
Private Declare Function RasHangUp Lib "rasapi32.dll" Alias "RasHangUpA"
(ByVal handle As Long) As Integer
Private Declare Function RasDial Lib "rasapi32.dll" Alias "RasDialA"
(ByVal p1 As Long, ByVal p2 As Long, rd As RASDIALPARAMS, ByVal p4 As
Long, ByVal p5 As Long, handle As Long) As Integer
Private Declare Sub RasGetErrorString Lib "rasapi32.dll" Alias
"RasGetErrorStringA" (ByVal nmumer As Long, ByVal buffer As String,
ByVal sizebuf As Long)
Private Declare Function RasGetConnectStatus Lib "rasapi32.dll" Alias "
RasGetConnectStatusA" (ByVal handle As Long, estruc_estado As
RASCONNSTATUS) As Integer
'##################
Dim hDial As Long 'handle de la conexion
Const Conectado = 1
Const Desconectado = -1
'##################
Dim Nerror As Long
Dim origen As String
Dim destino As String


Function Conectar(entry As String, user As String, pass As String) As
Integer
Dim rdp As RASDIALPARAMS
rdp.dwSize = 1052
strcpyn rdp.szEntryName, entry + Chr$(0), 256
strcpyn rdp.szPhoneNumber, Chr$(0), 128
strcpyn rdp.szCallbackNumber, Chr$(0), 128
strcpyn rdp.szUserName, user + Chr$(0), 256
strcpyn rdp.szPassword, pass + Chr$(0), 256
strcpyn rdp.szDomain, Chr$(0), 15
Conectar = RasDial(0, 0, rdp, 0, 0, hDial)
End Function
 

Leer las respuestas

#1 Robin
07/10/2005 - 04:22 | Informe spam
Esto fue algo que una vez usé con c# de repente te da ideas
http://www.codeproject.com/Purgatory/rasdemo.asp


Robin Hernández

"infojerez" wrote in message
news:
Hola.

Estoy intentando modificar la API rasdial para vb.net que tengo para vb6
pero no logro hacerla funcionar, ¿alguien la tiene para vb.net?

Gracias y saludos

p.d.
El siguiente codigo me funciona perfectamente para vb6

Private Type RASDIALPARAMS
dwSize As Long
szEntryName As String * 257
szPhoneNumber As String * 129
szCallbackNumber As String * 129
szUserName As String * 257
szPassword As String * 257
szDomain As String * 16
filler As String * 16
End Type
Private Type RASCONNSTATUS
dwSize As Long
Estado As Integer
filler As String * 160
End Type
Private Declare Sub Sleep Lib "kernel32.dll" (ByVal miliseg As Long)
Private Declare Sub strcpyn Lib "kernel32.dll" Alias "lstrcpynA" (ByVal A
As String, ByVal de As String, ByVal n As Long)
Private Declare Function strlen Lib "kernel32.dll" Alias "lstrlenA" (ByVal
texto As String) As Long
Private Declare Function RasHangUp Lib "rasapi32.dll" Alias "RasHangUpA"
(ByVal handle As Long) As Integer
Private Declare Function RasDial Lib "rasapi32.dll" Alias "RasDialA"
(ByVal p1 As Long, ByVal p2 As Long, rd As RASDIALPARAMS, ByVal p4 As
Long, ByVal p5 As Long, handle As Long) As Integer
Private Declare Sub RasGetErrorString Lib "rasapi32.dll" Alias
"RasGetErrorStringA" (ByVal nmumer As Long, ByVal buffer As String, ByVal
sizebuf As Long)
Private Declare Function RasGetConnectStatus Lib "rasapi32.dll" Alias "
RasGetConnectStatusA" (ByVal handle As Long, estruc_estado As
RASCONNSTATUS) As Integer
'##################
Dim hDial As Long 'handle de la conexion
Const Conectado = 1
Const Desconectado = -1
'##################
Dim Nerror As Long
Dim origen As String
Dim destino As String


Function Conectar(entry As String, user As String, pass As String) As
Integer
Dim rdp As RASDIALPARAMS
rdp.dwSize = 1052
strcpyn rdp.szEntryName, entry + Chr$(0), 256
strcpyn rdp.szPhoneNumber, Chr$(0), 128
strcpyn rdp.szCallbackNumber, Chr$(0), 128
strcpyn rdp.szUserName, user + Chr$(0), 256
strcpyn rdp.szPassword, pass + Chr$(0), 256
strcpyn rdp.szDomain, Chr$(0), 15
Conectar = RasDial(0, 0, rdp, 0, 0, hDial)
End Function

Preguntas similares