Enable or disable internet connection of remote computers. Urgent!!
Halo i'm looking for ways to enable or disable internet connection of remote computers, like everythings are controlled by the server computer. I was told that there is a disconnect internet API and also a connect internet API. I would like to connect and disconnect the internet connection of remote computer which are connected to the internet through LAN. Can anyone give me some advise on this matter... A sampel would be nice.. Thanks alot..
Re: Enable or disable internet connection of remote computers. Urgent!!
try this one. hope this will help to solve your problem.
i just barrowed this code. :D
Declarations
VB Code:
Public Const RAS_MAXENTRYNAME As Integer = 256
Public Const RAS_MAXDEVICETYPE As Integer = 16
Public Const RAS_MAXDEVICENAME As Integer = 128
Public Const RAS_RASCONNSIZE As Integer = 412
Public Const ERROR_SUCCESS = 0&
Public Type RasEntryName
dwSize As Long
szEntryName(RAS_MAXENTRYNAME) As Byte
End Type
Public Type RasConn
dwSize As Long
hRasConn As Long
szEntryName(RAS_MAXENTRYNAME) As Byte
szDeviceType(RAS_MAXDEVICETYPE) As Byte
szDeviceName(RAS_MAXDEVICENAME) As Byte
End Type
Public Declare Function RasEnumConnections Lib _
"rasapi32.dll" Alias "RasEnumConnectionsA" (lpRasConn As _
Any, lpcb As Long, lpcConnections As Long) As Long
Public Declare Function RasHangUp Lib "rasapi32.dll" Alias _
"RasHangUpA" (ByVal hRasConn As Long) As LongPublic gstrISPName As String
Public ReturnCode As Long
Procedure
VB Code:
Public Sub HangUp()
Dim i As Long
Dim lpRasConn(255) As RasConn
Dim lpcb As Long
Dim lpcConnections As Long
Dim hRasConn As Long
lpRasConn(0).dwSize = RAS_RASCONNSIZE
lpcb = RAS_MAXENTRYNAME * lpRasConn(0).dwSize
lpcConnections = 0
ReturnCode = RasEnumConnections(lpRasConn(0), lpcb, _
lpcConnections)
If ReturnCode = ERROR_SUCCESS Then
For i = 0 To lpcConnections - 1
If Trim(ByteToString(lpRasConn(i).szEntryName)) _
= Trim(gstrISPName) Then
hRasConn = lpRasConn(i).hRasConn
ReturnCode = RasHangUp(ByVal hRasConn)
End If
Next i
End If
End Sub
Public Function ByteToString(bytString() As Byte) As String
Dim i As Integer
ByteToString = ""
i = 0
While bytString(i) = 0&
ByteToString = ByteToString & Chr(bytString(i))
i = i + 1
Wend
End Function
Using the HangUp Procedure
Once you have copied all required code into your project, you can hang up all connections to the telephone network by calling the procudure HangUp:
cheers,
-qhyzme-
Re: Enable or disable internet connection of remote computers. Urgent!!
Dear qhyzme
I have tried the way you suggested but nothing seem to be happening? Is it the coding is for dial up or broadband? The computers which i intend to disconnect its internet connection are using broadband. Need more help
Thanks alot
Re: Enable or disable internet connection of remote computers. Urgent!!
This line is having some problem
VB Code:
Public Declare Function RasHangUp Lib "rasapi32.dll" Alias _
"RasHangUpA" (ByVal hRasConn As Long) As LongPublic gstrISPName As String
Public ReturnCode As Long
The error message is Compiler error Expected: end of statement
Please help
Re: Enable or disable internet connection of remote computers. Urgent!!
Try doing this:
VB Code:
Public Declare Function RasHangUp Lib "rasapi32.dll" Alias _
"RasHangUpA" (ByVal hRasConn As Long) As Long 'split them up
Public gstrISPName As String
Public ReturnCode As Long
Re: Enable or disable internet connection of remote computers. Urgent!!
Thanks alot benmartin101 yesterday i have just found the original site which this coding was in and i have split up the coding but it still can't work.
Did anyone tried this coding before?? Can it work on your computer which is to disconnect the internet connection on LAN? I have tried but still it can't work. Hope someone can tell me or show me some example on this.
Re: Enable or disable internet connection of remote computers. Urgent!!
Can you guys help me to check this site out and try the coding
http://www.developerfusion.co.uk/show/247/
Can anyone get the coding to work?? What do we need to get it to work??
Please help me...
Re: Enable or disable internet connection of remote computers. Urgent!!
You guys i have given up on this coding as i have find out that the code can only cater to dial up and not for LAN connection.
Its ok as i have found a new way to do this.
Thanks to all who have help me. I have start a new thread so please help me there ok. Thanks alot You guys are the best :thumb: