J'ai testé ce code avec Windows Me et VB6 et il fonctionne tres bien
fait un Copier/coller de ce code dans une feuille (Form1) puis connecte toi et lance ce code
Option Explicit
'RasEnumConnections Enumere les connexions actives
Private Declare Function RasEnumConnections Lib "rasapi32.dll" Alias "RasEnumConnectionsA" ( _
lpRasConn As Any, _
lpcb As Long, _
lpcConnections As Long) As Long
Const RAS_MAXENTRYNAME = 256
Const RAS_RASCONNSIZE = 412
Private Type RasConn
dwSize As Long
hRasConn As Long
szEntryName(RAS_MAXENTRYNAME) As Byte
End Type
'RasHangUp Coupe les connexions actives en liaison avec RasEnumConnections
Private Declare Function RasHangUp Lib "rasapi32.dll" Alias "RasHangUpA" ( _
ByVal hRasConn As Long) As Long
Private Sub Form_Load()
Dim lpRasConn(255) As RasConn, lpcb As Long
Dim lpcConnections As Long, hRasConn As Long
lpRasConn(0).dwSize = RAS_RASCONNSIZE
lpcb = RAS_MAXENTRYNAME * lpRasConn(0).dwSize
lpcConnections = 0
'Liste les connexions
RasEnumConnections lpRasConn(0), lpcb, lpcConnections
hRasConn = lpRasConn(0).hRasConn
'Coupe la connexion
RasHangUp ByVal hRasConn
End Sub
Tien moi au courant si tu a encore des prob ou pas
Bonne Prog A+
MD
> > -------------------------------
> > Réponse au message :
> > -------------------------------
> >
> > > Encore une erreur :-(, au niveau de :
> > >
> > >
> > > PrivateType RasConn
> > >
> > > Il me dit incorretct en dehors d'une porcédure.
> > > Tu pourais mettre une source toute faite qui deconnecte internet sur VBFrance stp. Merci
> > > -------------------------------
> > > Réponse au message :
> > > -------------------------------
> > >
> > > > Il faut remplacer Public par Private comme ici
> > > >
> > > > > 'RasEnumConnections Enumere les connexions actives
> > > > > Private Declare Function RasEnumConnections Lib "rasapi32.dll" Alias "RasEnumConnectionsA" ( _
> > > > > lpRasConn As Any, _
> > > > > lpcb As Long, _
> > > > > lpcConnections As Long) As Long
> > > > > 'RasHangUp Coupe les connexions actives en liaison avec RasEnumConnections
> > > > > Private Declare Function RasHangUp Lib "rasapi32.dll" Alias "RasHangUpA" ( _
> > > > > ByVal hRasConn As Long) As Long
> > > > > Private Const RAS_MAXENTRYNAME = 256
> > > > > Private Const RAS_RASCONNSIZE = 412
> > > > > PrivateType RasConn
> > > > > dwSize As Long
> > > > > hRasConn As Long
> > > > > szEntryName(RAS_MAXENTRYNAME) As Byte
> > > > > End Type
> > > >
> > > > Un oubli de ma part
> > > > @+
> > > > MD
> > > >
> > > >
> > > > -------------------------------
> > > > Réponse au message :
> > > > -------------------------------
> > > >
> > > > > Il me met 1 erreur au niveau de :
> > > > >
> > > > > Public Const RAS_MAXENTRYNAME = 256
> > > > > Public Const RAS_RASCONNSIZE = 412
> > > > >
> > > > > Il me met l'erreur suivante :
> > > > >
> > > > > Qu'est ce que je dois faire ?
> > > > >
> > > > >
> > > > > -------------------------------
> > > > > Réponse au message :
> > > > > -------------------------------
> > > > >
> > > > > > Essaye ça
> > > > > >
> > > > > > 'RasEnumConnections Enumere les connexions actives
> > > > > > Public Declare Function RasEnumConnections Lib "rasapi32.dll" Alias "RasEnumConnectionsA" ( _
> > > > > > lpRasConn As Any, _
> > > > > > lpcb As Long, _
> > > > > > lpcConnections As Long) As Long
> > > > > > 'RasHangUp Coupe les connexions actives en liaison avec RasEnumConnections
> > > > > > Public Declare Function RasHangUp Lib "rasapi32.dll" Alias "RasHangUpA" ( _
> > > > > > ByVal hRasConn As Long) As Long
> > > > > > Public Const RAS_MAXENTRYNAME = 256
> > > > > > Public Const RAS_RASCONNSIZE = 412
> > > > > > Public Type RasConn
> > > > > > dwSize As Long
> > > > > > hRasConn As Long
> > > > > > szEntryName(RAS_MAXENTRYNAME) As Byte
> > > > > > End Type
> > > > > >
> > > > > > Private Sub Form_Load()
> > > > > > Dim lpRasConn(255) As RasConn, lpcb As Long
> > > > > > Dim lpcConnections As Long, hRasConn As Long
> > > > > > '
> > > > > > lpRasConn(0).dwSize = RAS_RASCONNSIZE
> > > > > > lpcb = RAS_MAXENTRYNAME * lpRasConn(0).dwSize
> > > > > > lpcConnections = 0
> > > > > > 'Liste des connexions
> > > > > > RasEnumConnections lpRasConn(0), lpcb, lpcConnections
> > > > > > hRasConn = lpRasConn(0).hRasConn
> > > > > > 'Coupe la connexion
> > > > > > RasHangUp ByVal hRasConn
> > > > > > End Sub
> > > > > >
> > > > > > Bonne prog
> > > > > > MD
> > > > > >
> > > > > >
> > > > > > -------------------------------
> > > > > > Réponse au message :
> > > > > > -------------------------------
> > > > > >
> > > > > > > Bonjour, je veux faire un porig qui deconencte internet....j'ai essayé la chose suivante :
> > > > > > >
> > > > > > > Private Declare Function InternetAutodialHangup Lib "wininet.dll" _
> > > > > > > (ByVal dwReserved As Long) _
> > > > > > > As Long
> > > > > > > 'et apres dans une procedure :
> > > > > > > InternetAutodialHangup (0&)
> > > > > > >
> > > > > > > J'ai Windows 2000 et cette commande marche pas ! quelle est celle quimarche et, si possible sur toutes les version de windows ? Merci d'avance
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
>
>
> Option Explicit
>
> 'RasEnumConnections Enumere les connexions actives
> Private Declare Function RasEnumConnections Lib "rasapi32.dll" Alias "RasEnumConnectionsA" ( _
> lpRasConn As Any, _
> lpcb As Long, _
> lpcConnections As Long) As Long
> Const RAS_MAXENTRYNAME = 256
> Const RAS_RASCONNSIZE = 412
> Private Type RasConn
> dwSize As Long
> hRasConn As Long
> szEntryName(RAS_MAXENTRYNAME) As Byte
> End Type
> 'RasHangUp Coupe les connexions actives en liaison avec RasEnumConnections
> Private Declare Function RasHangUp Lib "rasapi32.dll" Alias "RasHangUpA" ( _
> ByVal hRasConn As Long) As Long
>
> Private Sub Form_Load()
> Dim lpRasConn(255) As RasConn, lpcb As Long
> Dim lpcConnections As Long, hRasConn As Long
> lpRasConn(0).dwSize = RAS_RASCONNSIZE
> lpcb = RAS_MAXENTRYNAME * lpRasConn(0).dwSize
> lpcConnections = 0
> 'Liste les connexions
> RasEnumConnections lpRasConn(0), lpcb, lpcConnections
> hRasConn = lpRasConn(0).hRasConn
> 'Coupe la connexion
> RasHangUp ByVal hRasConn
> End Sub
>
>