public bool Start(SharableConnection sharedConnection) { try { this.Stop(); this.wlanManager.StartHostedNetwork(); Thread.Sleep(1000); if (sharedConnection != null) { if (sharedConnection.Guid != Guid.Empty) { if (this.icsManager.SharingInstalled) { var privateConnectionGuid = this.wlanManager.HostedNetworkInterfaceGuid; if (privateConnectionGuid == Guid.Empty) { // If the GUID for the Hosted Network Adapter isn't return properly, // then retrieve it by the DeviceName. privateConnectionGuid = (from c in this.icsManager.Connections where c.props.DeviceName.ToLowerInvariant().Contains("microsoft virtual wifi miniport adapter") || // Windows 7 c.props.DeviceName.ToLowerInvariant().Contains("microsoft hosted network virtual adapter") || // Windows 8 c.props.DeviceName.ToLowerInvariant().Contains("microsoft állandó hálózati virtuális adapter") // Hungarian local select c.Guid).FirstOrDefault(); // Note: For some reason the DeviceName can have different names, currently it checks for the ones that I have identified thus far. if (privateConnectionGuid == Guid.Empty) { // Device still now found, so throw exception so the message gets raised up to the client. throw new Exception("Virtual Wifi device not found!\n\nNeither \"Microsoft Hosted Network Virtual Adapter\" or \"Microsoft Virtual Wifi Miniport Adapter\" or \"Microsoft állandó hálózati virtuális adapter\" were found."); } } this.icsManager.EnableIcs(sharedConnection.Guid, privateConnectionGuid); this.currentSharedConnection = sharedConnection; } } } else { this.currentSharedConnection = null; } return(true); } catch (Exception ex) { this._lastErrorMessage = ex.Message; return(false); } }
public bool Start(SharableConnection sharedConnection) { try { this.Stop(); this.wlanManager.StartHostedNetwork(); Thread.Sleep(1000); if (sharedConnection != null) { if (sharedConnection.Guid != Guid.Empty) { if (this.icsManager.SharingInstalled) { var privateConnectionGuid = this.wlanManager.HostedNetworkInterfaceGuid; if (privateConnectionGuid == Guid.Empty) { // If the GUID for the Hosted Network Adapter isn't return properly, // then retrieve it by the DeviceName. privateConnectionGuid = (from c in this.icsManager.Connections where c.props.DeviceName.ToLowerInvariant().Contains("microsoft virtual wifi miniport adapter") // Windows 7 || c.props.DeviceName.ToLowerInvariant().Contains("microsoft hosted network virtual adapter") // Windows 8 select c.Guid).FirstOrDefault(); // Note: For some reason the DeviceName can have different names, currently it checks for the ones that I have identified thus far. if (privateConnectionGuid == Guid.Empty) { // Device still now found, so throw exception so the message gets raised up to the client. throw new Exception("Virtual Wifi device not found!\n\nNeither \"Microsoft Hosted Network Virtual Adapter\" or \"Microsoft Virtual Wifi Miniport Adapter\" were found."); } } this.icsManager.EnableIcs(sharedConnection.Guid, privateConnectionGuid); this.currentSharedConnection = sharedConnection; } } } else { this.currentSharedConnection = null; } return true; } catch(Exception ex) { this._lastErrorMessage = ex.Message; return false; } }
public bool Start(SharableConnection sharedConnection) { try { this.Stop(); this.wlanManager.StartHostedNetwork(); Thread.Sleep(1000); if (sharedConnection != null) { if (sharedConnection.Guid != Guid.Empty) { if (this.icsManager.SharingInstalled) { var privateConnectionGuid = this.wlanManager.HostedNetworkInterfaceGuid; if (privateConnectionGuid == Guid.Empty) { // If the GUID for the Hosted Network Adapter isn't return properly, // then retrieve it by the DeviceName. //foreach (var c in this.icsManager.Connections) //{ //LogProvider.Instance.Info(c.props.DeviceName); // string text = "test"; // System.IO.File.WriteAllText(@"C:\Users\Public\TestFolder\WriteText.txt", c.props.DeviceName); //} privateConnectionGuid = (from c in this.icsManager.Connections where c.props.DeviceName.ToLowerInvariant().Contains("microsoft virtual wifi miniport adapter") || // Windows 7 c.props.DeviceName.ToLowerInvariant().Contains("microsoft hosted network virtual adapter") || // Windows 8 c.props.DeviceName.ToLowerInvariant().Contains("von microsoft gehosteter, virtueller netzwerkadapter") || // Windows 8 german c.props.DeviceName.ToLowerInvariant().Contains("Adaptador virtual de red hospedada de Microsoft") || // Windows 8 spanish c.props.DeviceName.ToLowerInvariant().Contains("виртуальный адаптер размещенной сети (майкрософт)") || //Windows 8 russian c.props.DeviceName.ToLowerInvariant().Contains("Carte virtuelle de réseau hébergé Microsoft") // Windows 8 french select c.Guid).FirstOrDefault(); // Note: For some reason the DeviceName can have different names, currently it checks for the ones that I have identified thus far. if (privateConnectionGuid == Guid.Empty) { // Device still now found, so throw exception so the message gets raised up to the client. throw new Exception("Virtual Wifi device not found!\n\nNeither \"Microsoft Hosted Network Virtual Adapter\" or \"Microsoft Virtual Wifi Miniport Adapter\" were found."); } } this.icsManager.EnableIcs(sharedConnection.Guid, privateConnectionGuid); this.currentSharedConnection = sharedConnection; } } } else { this.currentSharedConnection = null; } return(true); } catch (Exception ex) { this._lastErrorMessage = ex.Message; return(false); } }
public bool Start(SharableConnection sharedConnection) { try { this.Stop(); this.wlanManager.StartHostedNetwork(); Thread.Sleep(1000); if (sharedConnection != null) { if (sharedConnection.Guid != Guid.Empty) { if (this.icsManager.SharingInstalled) { var privateConnectionGuid = this.wlanManager.HostedNetworkInterfaceGuid; if (privateConnectionGuid == Guid.Empty) { // If the GUID for the Hosted Network Adapter isn't return properly, // then retrieve it by the DeviceName. //foreach (var c in this.icsManager.Connections) //{ //LogProvider.Instance.Info(c.props.DeviceName); // string text = "test"; // System.IO.File.WriteAllText(@"C:\Users\Public\TestFolder\WriteText.txt", c.props.DeviceName); //} privateConnectionGuid = (from c in this.icsManager.Connections where c.props.DeviceName.ToLowerInvariant().Contains("microsoft virtual wifi miniport adapter") // Windows 7 || c.props.DeviceName.ToLowerInvariant().Contains("microsoft hosted network virtual adapter") // Windows 8 || c.props.DeviceName.ToLowerInvariant().Contains("von microsoft gehosteter, virtueller netzwerkadapter") // Windows 8 german || c.props.DeviceName.ToLowerInvariant().Contains("Adaptador virtual de red hospedada de Microsoft") // Windows 8 spanish || c.props.DeviceName.ToLowerInvariant().Contains("виртуальный адаптер размещенной сети (майкрософт)") //Windows 8 russian || c.props.DeviceName.ToLowerInvariant().Contains("Carte virtuelle de réseau hébergé Microsoft") // Windows 8 french select c.Guid).FirstOrDefault(); // Note: For some reason the DeviceName can have different names, currently it checks for the ones that I have identified thus far. if (privateConnectionGuid == Guid.Empty) { // Device still now found, so throw exception so the message gets raised up to the client. throw new Exception("Virtual Wifi device not found!\n\nNeither \"Microsoft Hosted Network Virtual Adapter\" or \"Microsoft Virtual Wifi Miniport Adapter\" were found."); } } this.icsManager.EnableIcs(sharedConnection.Guid, privateConnectionGuid); this.currentSharedConnection = sharedConnection; } } } else { this.currentSharedConnection = null; } return true; } catch(Exception ex) { this._lastErrorMessage = ex.Message; return false; } }