Results 1 to 3 of 3

Thread: Disable/Enable Internet connection

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Apr 2004
    Location
    Philippines
    Posts
    285

    Disable/Enable Internet connection

    hello everyone, i was just wondering if there is way to enable/disable internet connection using vb? i'm running an internet cafe here and we have diffrent rates when a client would use internet or just encode/play games. when client only want to play games/ encode something, internet connection should be disabled. any help would be greatly appreciated thanks...

  2. #2
    PowerPoster lintz's Avatar
    Join Date
    Mar 2003
    Location
    The 19th Hole
    Posts
    2,697
    I found this code which may help you out

    VB Code:
    1. ' Switch Boolean (Scope: form or module level)
    2. Dim LANEnable As Boolean = True
    3.  
    4.         ' ***** Either placed within a button or routine *****
    5.  
    6.         ' Control Panel Identifier
    7.         Const ssfCONTROLS = 3
    8.  
    9.         ' Enter the name of the connection to manipulate
    10.         Dim ConnectionName As String = "Local Area Connection"
    11.         Dim EnableVerb As String = "En&able"
    12.         Dim DisableVerb As String = "Disa&ble"
    13.  
    14.         ' Generate Shell item
    15.         Dim ShellApp As New Shell32.Shell()
    16.         ' Obtain the CP
    17.         Dim ControlPanel As Shell32.Folder = ShellApp.NameSpace(ssfCONTROLS)
    18.         Dim FolderItem As Shell32.FolderItem
    19.         Dim NetworkFolder As Shell32.Folder
    20.         Dim LANConnection As Shell32.FolderItem
    21.  
    22.         ' Loop through the items in the control panel and obtain the Network Connections folder
    23.         For Each FolderItem In ControlPanel.Items()
    24.             Debug.WriteLine("Loop 1: " & FolderItem.Name)
    25.             If FolderItem.Name = "Network Connections" Then
    26.                 ' When found - exit the loop
    27.                 NetworkFolder = FolderItem.GetFolder
    28.                 Exit For
    29.             End If
    30.         Next
    31.  
    32.         ' Debug check
    33.         If NetworkFolder Is Nothing Then
    34.             MessageBox.Show("Error - No network folder found")
    35.             Exit Sub
    36.         End If
    37.  
    38.         ' Obtain the appropriate connection record
    39.         For Each FolderItem In NetworkFolder.Items()
    40.             Debug.WriteLine("Loop 2: " & FolderItem.Name)
    41.             If FolderItem.Name = ConnectionName Then
    42.                 ' When found - exit the loop
    43.                 LANConnection = FolderItem
    44.                 Exit For
    45.             End If
    46.         Next
    47.  
    48.         ' Debug check
    49.         If LANConnection Is Nothing Then
    50.             MessageBox.Show("Error - No LAN entry was not found")
    51.             Exit Sub
    52.         End If
    53.  
    54.         ' Swtich the LAN toggle
    55.         LANEnable = Not LANEnable
    56.  
    57.         Dim EnableVerbItem, DisableVerbItem, Verb As Shell32.FolderItemVerb
    58.  
    59.         ' Run through all available options and obtain the appropriate action
    60.         For Each Verb In LANConnection.Verbs
    61.             Debug.WriteLine("Loop 3: " & Verb.Name)
    62.             If Verb.Name = EnableVerb Then
    63.                 EnableVerbItem = Verb
    64.             End If
    65.             If Verb.Name = DisableVerb Then
    66.                 DisableVerbItem = Verb
    67.             End If
    68.         Next
    69.  
    70.         ' Perform the enable / disable
    71.         If LANEnable Then
    72.             EnableVerbItem.DoIt()
    73.         Else
    74.             DisableVerbItem.DoIt()
    75.         End If

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Apr 2004
    Location
    Philippines
    Posts
    285
    thanks for the immediate reply.. what does the code you gave me do? does it disable the lan connections??? that's how i understand it looking at ur code. if that's the case, i'm afraid its not exactly what i want to happen. you see, all client pcs connect to the server through winsock . that way, the server can control client pcs, if lan connection is disabled, then the server can no longer communicate with the clients

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