Microsoft Developer Network >
Página principal de foros
>
Visual Basic General
>
open Network properties UI from VB
open Network properties UI from VB
- Hi, I am developing a new shell for a windows project using VB2008.
I would like to open the network IP properties for the Local Area Connection, in order for the user to change the IP address for the computer.
I have done some research, but can't find any way of doing this through Process.Start("RunDll32.exe", "shell32.dll,....... like I have done with the other items I needed from the control panel, and the information I do find tells me to use the INetCfgComponent::RaisePropertyUi.
Unfortunatly I have no idea in how to use this function from within VB....
Any information on how to do this would be greatly appreciated.
Thanks,
Robin.
Welcome to my world
Todas las respuestas
- try to find the answer here:
http://www.computerhope.com/forum/index.php?topic=77071.0
http://www.codeguru.com/vb/
all the best for you...
DeepF1- Marcado como respuestaXingwei HuMSFT, Moderadormartes, 01 de septiembre de 2009 2:58
- Desmarcado como respuestaPlaywolf martes, 01 de septiembre de 2009 18:14
- The reply is not really very helpful... I have searched google and bing until I have gone blue in the face! I cannot seem to find any examples, someone must have done this!
Robin.
Welcome to my world - Please, someone must have done this in the past, even if it is in c# or c++, It is starting to get important now!
Many thanks,
Robin.
Welcome to my world Hi, I am developing a new shell for a windows project using VB2008.
I would like to open the network IP properties for the Local Area Connection, in order for the user to change the IP address for the computer.
I would like to open the network IP properties for the Local Area Connection, in order for the user to change the IP address for the computer.
I have done some research, but can't find any way of doing this through Process.Start("RunDll32.exe", "shell32.dll,....... like I have done with the other items I needed from the control panel, and the information I do find tells me to use the INetCfgComponent::RaisePropertyUi.
Unfortunatly I have no idea in how to use this function from within VB....
Any information on how to do this would be greatly appreciated.
Thanks,
Robin.
Welcome to my world
I thing its imponsible to change the IP via Code..........
I did some resaerch as well but I cannot find it
Don't judge me, just Upgrade me. Thanks!- OK, I found a possible solution:
It works fine on Vista and 7, but when trying it with XP (which is the one it NEEDS to work on, it fails to show the dialog box.Imports System.Management Public Class SelectNetworkAdapter Dim ConnectionName As String = Nothing ' = "Local Area Connection" Private Sub SelectNetworkAdapter_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load '"Local Area Connection" getNetworkAdapters(ConnectionName) lstNetworkAdapter.SelectedItem = lstNetworkAdapter.Items.Item(0) If lstNetworkAdapter.Items.Count = 1 Then openNetworkConnectionProperties() End If End Sub Private Sub btnOK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOK.Click openNetworkConnectionProperties() End Sub Public Sub openNetworkConnectionProperties() lstNetworkAdapter.Enabled = False btnOK.Enabled = False Dim SelectedAdapter As String = getNetworkAdapterGUID(lstNetworkAdapter.SelectedItem) 'MsgBox(SelectedAdapter) Shell("explorer.exe ::{20D04FE0-3AEA-1069-A2D8-08002B30309D}\::{21EC2020-3AEA-1069-A2DD-08002B30309D}\::{7007ACC7-3202-11D1-AAD2-00805FC1270E}\::" & SelectedAdapter) Me.Close() End Sub Private Function getNetworkAdapters(Optional ByVal ConnectionName As String = "") Try ' ' Create the query, in SQL syntax, to retrieve the properties from ' the active Network Adapter. ' Dim strQuery As String If Not ConnectionName = "" Then strQuery = String.Format("SELECT * FROM Win32_NetworkAdapter WHERE AdapterType = 'Ethernet 802.3' AND NetConnectionID LIKE '{0}'", ConnectionName) Else strQuery = "SELECT * FROM Win32_NetworkAdapter WHERE AdapterType = 'Ethernet 802.3'" End If ' "SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled = True" ' ' Create a ManagementObjectSearcher object passing in the query to run. ' Dim query As ManagementObjectSearcher = New ManagementObjectSearcher(strQuery) ' ' Create a ManagementObjectCollection assigning it the results of the query. ' Dim queryCollection As ManagementObjectCollection = query.Get() ' ' Loop through the results extracting the MAC Address. ' Dim mo As ManagementObject Dim strObject As String = Nothing For Each mo In queryCollection strObject = mo("Description") lstNetworkAdapter.Items.Add(strObject) Next Return True Catch ex As Exception MsgBox(ex.Message) Return False End Try End Function Private Function getNetworkAdapterGUID(ByVal Description As String) Try ' ' Create the query, in SQL syntax, to retrieve the properties from ' the active Network Adapter. ' Dim strQuery As String = _ String.Format("SELECT * FROM Win32_NetworkAdapterConfiguration WHERE Description LIKE '{0}'", Description) ' "SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled = True" ' ' Create a ManagementObjectSearcher object passing in the query to run. ' Dim query As ManagementObjectSearcher = New ManagementObjectSearcher(strQuery) ' ' Create a ManagementObjectCollection assigning it the results of the query. ' Dim queryCollection As ManagementObjectCollection = query.Get() ' ' Loop through the results extracting the SettingID/GUID of the device. ' Dim mo As ManagementObject Dim strObject As String = Nothing For Each mo In queryCollection strObject = mo("SettingID") Next Return strObject Catch ex As Exception MsgBox(ex.Message) Return False End Try End Function Public Sub New() ' This call is required by the Windows Form Designer. InitializeComponent() ' Add any initialization after the InitializeComponent() call. End Sub End Class
the main part of the code is: Shell("explorer.exe ::{20D04FE0-3AEA-1069-A2D8-08002B30309D}\::{21EC2020-3AEA-1069-A2DD-08002B30309D}\::{7007ACC7-3202-11D1-AAD2-00805FC1270E}\::" & SelectedAdapter)
Does anyone have a solution, or know where I could find one?
Regards,
Robin.
Welcome to my world

