Results 1 to 8 of 8

Thread: Enable or disable internet connection of remote computers. Urgent!!

  1. #1

    Thread Starter
    Member
    Join Date
    Feb 2006
    Posts
    61

    Exclamation 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..

  2. #2
    New Member
    Join Date
    Mar 2006
    Posts
    4

    Cool 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.

    Declarations

    VB Code:
    1. Public Const RAS_MAXENTRYNAME As Integer = 256
    2. Public Const RAS_MAXDEVICETYPE As Integer = 16
    3. Public Const RAS_MAXDEVICENAME As Integer = 128
    4. Public Const RAS_RASCONNSIZE As Integer = 412
    5. Public Const ERROR_SUCCESS = 0&
    6.  
    7. Public Type RasEntryName
    8.     dwSize As Long
    9.     szEntryName(RAS_MAXENTRYNAME) As Byte
    10. End Type
    11.  
    12. Public Type RasConn
    13.     dwSize As Long
    14.     hRasConn As Long
    15.     szEntryName(RAS_MAXENTRYNAME) As Byte
    16.     szDeviceType(RAS_MAXDEVICETYPE) As Byte
    17.     szDeviceName(RAS_MAXDEVICENAME) As Byte
    18. End Type
    19.  
    20. Public Declare Function RasEnumConnections Lib _
    21. "rasapi32.dll" Alias "RasEnumConnectionsA" (lpRasConn As _
    22. Any, lpcb As Long, lpcConnections As Long) As Long
    23.  
    24. Public Declare Function RasHangUp Lib "rasapi32.dll" Alias _
    25. "RasHangUpA" (ByVal hRasConn As Long) As LongPublic gstrISPName As String
    26. Public ReturnCode As Long


    Procedure

    VB Code:
    1. Public Sub HangUp()
    2. Dim i As Long
    3. Dim lpRasConn(255) As RasConn
    4. Dim lpcb As Long
    5. Dim lpcConnections As Long
    6. Dim hRasConn As Long
    7. lpRasConn(0).dwSize = RAS_RASCONNSIZE
    8. lpcb = RAS_MAXENTRYNAME * lpRasConn(0).dwSize
    9. lpcConnections = 0
    10. ReturnCode = RasEnumConnections(lpRasConn(0), lpcb, _
    11. lpcConnections)
    12.  
    13. If ReturnCode = ERROR_SUCCESS Then
    14.     For i = 0 To lpcConnections - 1
    15.         If Trim(ByteToString(lpRasConn(i).szEntryName)) _
    16.             = Trim(gstrISPName) Then
    17.             hRasConn = lpRasConn(i).hRasConn
    18.             ReturnCode = RasHangUp(ByVal hRasConn)
    19.         End If
    20.     Next i
    21. End If
    22.  
    23. End Sub
    24.  
    25. Public Function ByteToString(bytString() As Byte) As String
    26. Dim i As Integer
    27. ByteToString = ""
    28. i = 0
    29. While bytString(i) = 0&
    30. ByteToString = ByteToString & Chr(bytString(i))
    31. i = i + 1
    32. Wend
    33. 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:

    VB Code:
    1. Call HangUp

    cheers,
    -qhyzme-

  3. #3

    Thread Starter
    Member
    Join Date
    Feb 2006
    Posts
    61

    Exclamation 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

  4. #4

    Thread Starter
    Member
    Join Date
    Feb 2006
    Posts
    61

    Exclamation Re: Enable or disable internet connection of remote computers. Urgent!!

    This line is having some problem

    VB Code:
    1. Public Declare Function RasHangUp Lib "rasapi32.dll" Alias _
    2. "RasHangUpA" (ByVal hRasConn As Long) As LongPublic gstrISPName As String
    3. Public ReturnCode As Long

    The error message is Compiler error Expected: end of statement

    Please help

  5. #5
    Frenzied Member
    Join Date
    Jul 2005
    Posts
    1,168

    Re: Enable or disable internet connection of remote computers. Urgent!!

    Try doing this:

    VB Code:
    1. Public Declare Function RasHangUp Lib "rasapi32.dll" Alias _
    2. "RasHangUpA" (ByVal hRasConn As Long) As Long  'split them up
    3.  
    4. Public gstrISPName As String
    5. Public ReturnCode As Long

  6. #6

    Thread Starter
    Member
    Join Date
    Feb 2006
    Posts
    61

    Talking 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.

  7. #7

    Thread Starter
    Member
    Join Date
    Feb 2006
    Posts
    61

    Exclamation 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...

  8. #8

    Thread Starter
    Member
    Join Date
    Feb 2006
    Posts
    61

    Talking 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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width