begin process at 2012 02 11 22:07:47
  Trouver un code source :
 
dans
 
Accueil > 

Code

 > 

API

 > FONCTIONS DE CONNEXION À INTERNET

FONCTIONS DE CONNEXION À INTERNET


 Information sur la source

Note :
3,33 / 10 - par 3 personnes
3,33 / 10

  • 1

  • 2

  • 3

  • 4

  • 5

  • 6

  • 7

  • 8

  • 9

  • 10
Catégorie :API Niveau :Débutant Date de création :03/05/2002 Date de mise à jour :03/05/2002 21:07:54 Vu :5 728

Auteur : flagyg

Ecrire un message privé
Commentaire sur cette source (11)
Ajouter un commentaire et/ou une note

 Description

voila 3 fonctions(aucune ne vient de moi:-(  )
la fonction IsConnected retourne true si vous êtes connecté à internet.
la fonction WebConnect affiche la feuille "connexion"
la fonction WebAutoConnect affiche la feuille "connexion" et se connecte directement
la fonction WebDeconnect se déconnecte à internet.

certaines constances et APIs ne servent à rien !!

Source

  • Public Const INTERNET_AUTODIAL_FORCE_ONLINE = 1
  • Public Const INTERNET_AUTODIAL_FORCE_UNATTENDED = 2
  • Public Const SOCKET_ERROR As Long = -1
  • Public Const ERROR_SUCCESS = 0
  • Public Const MAX_WSADescription = 256
  • Public Const MAX_WSASYSStatus = 128
  • Public Const MIN_SOCKETS_REQD As Long = 1
  • Public Const WS_VERSION_REQD As Long = &H101
  • Public Const WS_VERSION_MAJOR As Long = WS_VERSION_REQD \ &H100 And &HFF&
  • Public Const WS_VERSION_MINOR As Long = WS_VERSION_REQD And &HFF&
  • Public Const RAS95_MaxEntryName = 256
  • Public Const RAS95_MaxDeviceType = 16
  • Public Const RAS95_MaxDeviceName = 32
  • Public Const LVM_FIRST = &H1000
  • Public Const LVM_SETCOLUMNWIDTH = LVM_FIRST + 30
  • Public Const LVSCW_AUTOSIZE = -1
  • Public Type RASCONN95
  • dwSize As Long
  • hRasCon As Long
  • szEntryName(RAS95_MaxEntryName) As Byte
  • szDeviceType(RAS95_MaxDeviceType) As Byte
  • szDeviceName(RAS95_MaxDeviceName) As Byte
  • End Type
  • Public Type RASCONNSTATUS95
  • dwSize As Long
  • RasConnState As Long
  • dwError As Long
  • szDeviceType(RAS95_MaxDeviceType) As Byte
  • szDeviceName(RAS95_MaxDeviceName) As Byte
  • End Type
  • Public Type WSAdata
  • wVersion As Integer
  • wHighVersion As Integer
  • szDescription(0 To MAX_WSADescription) As Byte
  • szSystemStatus(0 To MAX_WSASYSStatus) As Byte
  • wMaxSockets As Integer
  • wMaxUDPDG As Integer
  • dwVendorInfo As Long
  • End Type
  • Public Type Hostent
  • hName As Long
  • hAliases As Long
  • hAddrType As Integer
  • hLen As Integer
  • hAddrList As Long
  • End Type
  • Public Type IP_OPTION_INFORMATION
  • TTL As Byte
  • Tos As Byte
  • Flags As Byte
  • OptionsSize As Long
  • OptionsData As String * 128
  • End Type
  • Public Type IP_ECHO_REPLY
  • Address(0 To 3) As Byte
  • Status As Long
  • RoundTripTime As Long
  • DataSize As Integer
  • Reserved As Integer
  • Data As Long
  • Options As IP_OPTION_INFORMATION
  • End Type
  • Public Declare Function WSACleanup Lib "WSOCK32" () As Long
  • Public Declare Function IcmpCreateFile Lib "icmp.dll" () As Long
  • Public Declare Function WSAGetLastError Lib "WSOCK32" () As Long
  • Public Declare Function IcmpCloseHandle Lib "icmp.dll" (ByVal HANDLE As Long) As Boolean
  • Public Declare Function GetHostByName Lib "WSOCK32" Alias "gethostbyname" (ByVal szHost As String) As Long
  • Public Declare Function gethostname Lib "WSOCK32" (ByVal szHost As String, ByVal dwHostLen As Long) As Long
  • Public Declare Function WSAStartup Lib "WSOCK32" (ByVal wVersionRequired As Long, lpWSAdata As WSAdata) As Long
  • Public Declare Function RasEnumConnections Lib "RasApi32.dll" Alias "RasEnumConnectionsA" (lpRasCon As Any, lpcb As Long, lpcConnections As Long) As Long
  • Public Declare Function RasGetConnectStatus Lib "RasApi32.dll" Alias "RasGetConnectStatusA" (ByVal hRasCon As Long, lpStatus As Any) As Long
  • Public Declare Function InternetAutodial Lib "wininet.dll" (ByVal dwFlags As Long, ByVal dwReserved As Long) As Long
  • Public Declare Function InternetAutodialHangup Lib "wininet.dll" (ByVal dwReserved As Long) As Long
  • Public Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
  • Public Declare Function InternetGetLastResponseInfo Lib "wininet.dll" Alias "InternetGetLastResponseInfoA" (lpdwError As Long, ByVal lpszBuffer As String, lpdwBufferLength As Long) As Boolean
  • Public Declare Function IcmpSendEcho Lib "ICMP" (ByVal IcmpHandle As Long, ByVal DestAddress As Long, ByVal RequestData As String, ByVal RequestSize As Integer, RequestOptns As IP_OPTION_INFORMATION, ReplyBuffer As IP_ECHO_REPLY, ByVal ReplySize As Long, ByVal TimeOut As Long) As Boolean
  • Public Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (hpvDest As Any, hpvSource As Any, ByVal cbCopy As Long)
  • Public Declare Sub CopyMemoryIP Lib "kernel32" Alias "RtlMoveMemory" (hpvDest As Any, ByVal hpvSource As Long, ByVal cbCopy As Long)
  • '-------------------------------------------------------------
  • Function WebConnect() As Boolean
  • If InternetAutodial(INTERNET_AUTODIAL_FORCE_ONLINE, 0) Then 'affiche la feuille"Se connecter"
  • WebConnect = True 'true si connecté
  • Else
  • WebConnect = False
  • End If
  • End Function
  • Function WebDeconnect() As Boolean 'Se déconnecte automatiquement
  • If InternetAutodialHangup(0) Then
  • WebDeconnect = True
  • Else
  • WebDeconnect = False
  • End If
  • End Function
  • Function WebAutoConnect() As Boolean 'affiche la feuille "Se connecter" et se connecte automatiquement
  • If InternetAutodial(INTERNET_AUTODIAL_FORCE_UNATTENDED, 0) Then
  • WebAutoConnect = True
  • Else
  • WebAutoConnect = False
  • End If
  • End Function
  • Function IsConnected() As Boolean
  • Dim TRasCon(255) As RASCONN95
  • Dim lg As Long
  • Dim lpcon As Long
  • Dim RetVal As Long
  • Dim Tstatus As RASCONNSTATUS95
  • TRasCon(0).dwSize = 412
  • lg = 256 * TRasCon(0).dwSize
  • RetVal = RasEnumConnections(TRasCon(0), lg, lpcon)
  • If RetVal <> 0 Then
  • MsgBox "ERROR", vbExclamation, "ERROR"
  • Exit Function
  • End If
  • Tstatus.dwSize = 160
  • RetVal = RasGetConnectStatus(TRasCon(0).hRasCon, Tstatus)
  • If Tstatus.RasConnState = &H2000 Then
  • IsConnected = True
  • Else
  • IsConnected = False
  • End If
  • End Function
Public Const INTERNET_AUTODIAL_FORCE_ONLINE = 1
 Public Const INTERNET_AUTODIAL_FORCE_UNATTENDED = 2
 Public Const SOCKET_ERROR As Long = -1
 Public Const ERROR_SUCCESS = 0
 Public Const MAX_WSADescription = 256
 Public Const MAX_WSASYSStatus = 128
 Public Const MIN_SOCKETS_REQD As Long = 1
 Public Const WS_VERSION_REQD As Long = &H101
 Public Const WS_VERSION_MAJOR As Long = WS_VERSION_REQD \ &H100 And &HFF&
 Public Const WS_VERSION_MINOR As Long = WS_VERSION_REQD And &HFF&
 Public Const RAS95_MaxEntryName = 256
 Public Const RAS95_MaxDeviceType = 16
 Public Const RAS95_MaxDeviceName = 32
 Public Const LVM_FIRST = &H1000
 Public Const LVM_SETCOLUMNWIDTH = LVM_FIRST + 30
 Public Const LVSCW_AUTOSIZE = -1
 
 Public Type RASCONN95
    dwSize As Long
    hRasCon As Long
    szEntryName(RAS95_MaxEntryName) As Byte
    szDeviceType(RAS95_MaxDeviceType) As Byte
    szDeviceName(RAS95_MaxDeviceName) As Byte
  End Type
  Public Type RASCONNSTATUS95
    dwSize As Long
    RasConnState As Long
    dwError As Long
    szDeviceType(RAS95_MaxDeviceType) As Byte
    szDeviceName(RAS95_MaxDeviceName) As Byte
  End Type
  Public Type WSAdata
    wVersion As Integer
    wHighVersion As Integer
    szDescription(0 To MAX_WSADescription) As Byte
    szSystemStatus(0 To MAX_WSASYSStatus) As Byte
    wMaxSockets As Integer
    wMaxUDPDG As Integer
    dwVendorInfo As Long
End Type
 Public Type Hostent
    hName As Long
    hAliases As Long
    hAddrType As Integer
    hLen As Integer
    hAddrList As Long
End Type
 Public Type IP_OPTION_INFORMATION
    TTL As Byte
    Tos As Byte
    Flags As Byte
    OptionsSize As Long
    OptionsData As String * 128
End Type
 Public Type IP_ECHO_REPLY
    Address(0 To 3) As Byte
    Status As Long
    RoundTripTime As Long
    DataSize As Integer
    Reserved As Integer
    Data As Long
    Options As IP_OPTION_INFORMATION
End Type
 Public Declare Function WSACleanup Lib "WSOCK32" () As Long
 Public Declare Function IcmpCreateFile Lib "icmp.dll" () As Long
 Public Declare Function WSAGetLastError Lib "WSOCK32" () As Long
 Public Declare Function IcmpCloseHandle Lib "icmp.dll" (ByVal HANDLE As Long) As Boolean
 Public Declare Function GetHostByName Lib "WSOCK32" Alias "gethostbyname" (ByVal szHost As String) As Long
 Public Declare Function gethostname Lib "WSOCK32" (ByVal szHost As String, ByVal dwHostLen As Long) As Long
 Public Declare Function WSAStartup Lib "WSOCK32" (ByVal wVersionRequired As Long, lpWSAdata As WSAdata) As Long
 Public Declare Function RasEnumConnections Lib "RasApi32.dll" Alias "RasEnumConnectionsA" (lpRasCon As Any, lpcb As Long, lpcConnections As Long) As Long
 Public Declare Function RasGetConnectStatus Lib "RasApi32.dll" Alias "RasGetConnectStatusA" (ByVal hRasCon As Long, lpStatus As Any) As Long
 Public Declare Function InternetAutodial Lib "wininet.dll" (ByVal dwFlags As Long, ByVal dwReserved As Long) As Long
 Public Declare Function InternetAutodialHangup Lib "wininet.dll" (ByVal dwReserved As Long) As Long
 Public Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
 Public Declare Function InternetGetLastResponseInfo Lib "wininet.dll" Alias "InternetGetLastResponseInfoA" (lpdwError As Long, ByVal lpszBuffer As String, lpdwBufferLength As Long) As Boolean
 Public Declare Function IcmpSendEcho Lib "ICMP" (ByVal IcmpHandle As Long, ByVal DestAddress As Long, ByVal RequestData As String, ByVal RequestSize As Integer, RequestOptns As IP_OPTION_INFORMATION, ReplyBuffer As IP_ECHO_REPLY, ByVal ReplySize As Long, ByVal TimeOut As Long) As Boolean
 Public Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (hpvDest As Any, hpvSource As Any, ByVal cbCopy As Long)
 Public Declare Sub CopyMemoryIP Lib "kernel32" Alias "RtlMoveMemory" (hpvDest As Any, ByVal hpvSource As Long, ByVal cbCopy As Long)
'-------------------------------------------------------------
Function WebConnect() As Boolean
    If InternetAutodial(INTERNET_AUTODIAL_FORCE_ONLINE, 0) Then 'affiche la feuille"Se connecter"
        WebConnect = True 'true si connecté
    Else
        WebConnect = False
    End If
End Function
Function WebDeconnect() As Boolean 'Se déconnecte automatiquement
  If InternetAutodialHangup(0) Then
    WebDeconnect = True
  Else
    WebDeconnect = False
  End If
End Function
Function WebAutoConnect() As Boolean 'affiche la feuille "Se connecter" et se connecte automatiquement
    If InternetAutodial(INTERNET_AUTODIAL_FORCE_UNATTENDED, 0) Then
      WebAutoConnect = True
    Else
      WebAutoConnect = False
    End If
End Function
Function IsConnected() As Boolean
Dim TRasCon(255) As RASCONN95
Dim lg As Long
Dim lpcon As Long
Dim RetVal As Long
Dim Tstatus As RASCONNSTATUS95
TRasCon(0).dwSize = 412
lg = 256 * TRasCon(0).dwSize
RetVal = RasEnumConnections(TRasCon(0), lg, lpcon)
If RetVal <> 0 Then
                    MsgBox "ERROR", vbExclamation, "ERROR"
                    Exit Function
                    End If
Tstatus.dwSize = 160
RetVal = RasGetConnectStatus(TRasCon(0).hRasCon, Tstatus)
If Tstatus.RasConnState = &H2000 Then
                         IsConnected = True
                         Else
                         IsConnected = False
                         End If
End Function 

 Conclusion

si vous avez des question n'hésitez pas à m'écrire...


 Sources du même auteur

Source avec Zip CARAMAIL ;CHERCHEUR DE PASSWORD :-)
Source avec Zip CODEUR/DÉCODEUR DE TEXTE ( EN NOMBRES)2ÈME VERSION!!
Source avec Zip CONTROLLEUR DE JOYSTICK
Source avec Zip PROGRAMMEUR DE CURSEUR
Source avec Zip Source avec une capture CERCLES ONDULANTS

 Sources de la même categorie

Source avec Zip Source .NET (Dotnet) .NET DEPENDENCY VIEWER : ARBRE DES DÉPENDANCES D'UN ASSEMBLY... par ShareVB
Source avec Zip Source .NET (Dotnet) UTILITAIRE SKYDRIVE par MasterShadows
Source avec Zip ROTATION RAPIDE D'IMAGE par trex70
Source avec Zip Source avec une capture ENUMERATION DES PORTS TCP ET IDENTIFCATION DU PROCESS (PID) ... par Renfield
Source avec Zip Source avec une capture MOUSE SPEED AND WEIGHT : RETOUR DE FORCE VIRTUEL ! par ScSami

Commentaires et avis

Commentaire de Didiboy le 04/05/2002 11:26:30

g horreur des gars ki vont sur vbfrance pour foutre u ncode ne leur appartenant pas :
&gt;&gt;&gt;http://www.vbcode.com/asp/showsn.asp?theID=67

Commentaire de charlesvb le 04/05/2002 13:10:48

Du con Didiboy tu c'est pas lire? Regarde donc en haut avant de parler! lol
Bravo :P
En passant je donne 10 c'est nice la source!

Commentaire de Didiboy le 04/05/2002 19:46:02

exkuz, j'avais pas fait gaffe

Commentaire de Frecky le 11/05/2002 07:23:52

papire pour se crer un prog pour  se conecter automatiquement aik dotre setting. !
aussi ca peut etre pratique pour faire un ti prog vite qui fa disco le monde.. fake quand qqu te fa chier tu lui lsend ca pis i se fait disco ca conection modem :P lol

Commentaire de Psyllos le 13/05/2002 15:29:47

purée c moi ki louche ou ce k'a ecrit Frecky est po super compréhensible.... lol

Commentaire de totomaze le 30/07/2002 21:46:49

mais je ne comprend pas car comment ton prog peut ilse connecter si on ne lui dis pas le nom de la connection ou le nom d'utilisateur et le mot de passe
g mis un code qui se connecte a internet avec le nom de la connexion (pas de moi vbcode.com)

Commentaire de Jujufouq le 16/06/2003 01:49:09

Tu me fais rire quand tu dis que toutes les APIs ne sont pas utiles, c'est tellement vrai!  ;-)  

Commentaire de wallon14 le 21/04/2005 18:54:02

Public Const INTERNET_AUTODIAL_FORCE_ONLINE = 1
Public Const INTERNET_AUTODIAL_FORCE_UNATTENDED = 2

Public Declare Function InternetAutodial Lib "wininet.dll" (ByVal dwFlags As Long, ByVal dwReserved As Long) As Long
Public Declare Function InternetAutodialHangup Lib "wininet.dll" (ByVal dwReserved As Long) As Long

Function WebConnect() As Boolean
    Call InternetAutodial(INTERNET_AUTODIAL_FORCE_ONLINE, 0)
End Function
Function WebDeconnect() As Boolean 'Se déconnecte automatiquement
    Call InternetAutodialHangup(0)
End Function
Function WebAutoConnect() As Boolean 'affiche la feuille "Se connecter" et se connecte automatiquement
    Call InternetAutodial(INTERNET_AUTODIAL_FORCE_UNATTENDED, 0)
End Function






Ca suffit je pense...

Commentaire de bouazza92 le 28/12/2005 12:56:35

Bonjour,

Comment faire pour se connecter automatiquement mais sans afficher la fenetre SE CONNECTER ?
merci et bonnes fêtes !

Commentaire de VPNVB le 27/06/2007 11:47:44

Salut,
Bravo mon ami
c'est des functions tré utils
Tu peux M'aider ?
je veux trouver les API de Ras et RRAS...

Merci !

Commentaire de Raffaboy le 13/07/2009 07:12:03

Sa marche pour ack compte dofus aussi??

 Ajouter un commentaire




Nos sponsors


Sondage...

CalendriCode

Février 2012
LMMJVSD
  12345
6789101112
13141516171819
20212223242526
272829    

Consulter la suite du CalendriCode

Photothèque

 
Développement réalisé par Nicolas SOREL (Nix) avec l'aide de : Cyril DURAND et Emmanuel (EBArtSoft), Merci à Vincent pour ses précieux conseils.
CodeS-SourceS.com© Toute reproduction même partielle est interdite sauf accord écrit du Webmaster
CodeS-SourceS.com© est une marque déposée tous droits réservés

Google Coop CodeS-SourceS Google Coop CodeS-SourceS
Temps d'éxécution de la page : 1,326 sec (3)

Nous contacter | Annoncer sur CodeS-SourceS | Mentions légales