View Full Version : چطور میشه کانکشن شبکه رو Disable کرد ؟
  
vahab_vb
پنج شنبه 02 شهریور 1385, 10:20 صبح
سلام ، دوستان
یکی از مشکلات شبکه ADSL ، اینه که هر روز حداقل یکبار قطع میشه.
بنده همواره با این مشکل مواجه هستم.
اتصال ADSL بنده هم از نوع اتصال مستقیم هستش. 
هر وقت اتصال اینترنتم قطع میشه، با یکبار Disable و Enable کردن شبکه اینترنت دوباره اوضاع به حالت اولش برمیگرده.
من یه نرم افزاری برای جلوگیری از این قطع و وصل نوشتم که هر وقت این عمل اتقاق میفته، هشدار میده.
ولی اگر میشد کدی رو به زبان VB و یا با API مینوشتیم که در اون لحظه خودش کانکشن مربوطه رو بصورت خودکار Disable و Enable میکرد. خیلی عالی میشد.
دوستان راهی برای اینکار دارند ؟
bazikadeh
جمعه 22 شهریور 1392, 14:47 عصر
بعد از چند سال هنوز کسی نمیدونه
m.4.r.m
جمعه 22 شهریور 1392, 15:34 عصر
Dim LANEnable As Boolean = True 
 
        ' ***** Either placed within a button or routine ***** 
 
        ' Control Panel Identifier 
        Const ssfCONTROLS = 3 
 
        ' Enter the name of the connection to manipulate 
        Dim ConnectionName As String = "Local Area Connection" 
        Dim EnableVerb As String = "En&able" 
        Dim DisableVerb As String = "Disa&ble" 
 
        ' Generate Shell item 
        Dim ShellApp As New Shell32.Shell() 
        ' Obtain the CP 
        Dim ControlPanel As Shell32.Folder = ShellApp.NameSpace(ssfCONTROLS) 
        Dim FolderItem As Shell32.FolderItem 
        Dim NetworkFolder As Shell32.Folder 
        Dim LANConnection As Shell32.FolderItem 
 
        ' Loop through the items in the control panel and obtain the Network Connections folder 
        For Each FolderItem In ControlPanel.Items() 
            Debug.WriteLine("Loop 1: " & FolderItem.Name) 
            If FolderItem.Name = "Network Connections" Then 
                ' When found - exit the loop 
                NetworkFolder = FolderItem.GetFolder 
                Exit For 
            End If 
        Next 
 
        ' Debug check 
        If NetworkFolder Is Nothing Then 
            MessageBox.Show("Error - No network folder found") 
            Exit Sub 
        End If 
 
        ' Obtain the appropriate connection record 
        For Each FolderItem In NetworkFolder.Items() 
            Debug.WriteLine("Loop 2: " & FolderItem.Name) 
            If FolderItem.Name = ConnectionName Then 
                ' When found - exit the loop 
                LANConnection = FolderItem 
                Exit For 
            End If 
        Next 
 
        ' Debug check 
        If LANConnection Is Nothing Then 
            MessageBox.Show("Error - No LAN entry was not found") 
            Exit Sub 
        End If 
 
        ' Swtich the LAN toggle 
        LANEnable = Not LANEnable 
 
        Dim EnableVerbItem, DisableVerbItem, Verb As Shell32.FolderItemVerb 
 
        ' Run through all available options and obtain the appropriate action 
        For Each Verb In LANConnection.Verbs 
            Debug.WriteLine("Loop 3: " & Verb.Name) 
            If Verb.Name = EnableVerb Then 
                EnableVerbItem = Verb 
            End If 
            If Verb.Name = DisableVerb Then 
                DisableVerbItem = Verb 
            End If 
        Next 
 
        ' Perform the enable / disable 
        If LANEnable Then 
            EnableVerbItem.DoIt() 
        Else 
            DisableVerbItem.DoIt() 
        End If
bazikadeh
جمعه 22 شهریور 1392, 17:03 عصر
خوب اینو من قبلا دیدم ولی چطور اتصال میکنه ؟
بعدش با سی شارپ بلد نیستین ؟
 
vBulletin® v4.2.5, Copyright ©2000-1404, Jelsoft Enterprises Ltd.