By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,928 Members | 1,210 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,928 IT Pros & Developers. It's quick & easy.

Changing IP-Addres and Default Gateway

P: n/a
Hi

In VB6 i changed the IP-Adress and Gateway of the computer by using API. Is
there an object available in .net for doing this?

Thanks alot

Nijazi Halimaji
Nov 21 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
I haven't seen one. The easiest thing to do would be just expose your VB6
code as a COM class.

--
Jonathan Allen
"Nijazi Halimaji" <sp***@gmx.net> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
Hi

In VB6 i changed the IP-Adress and Gateway of the computer by using API.
Is there an object available in .net for doing this?

Thanks alot

Nijazi Halimaji

Nov 21 '05 #2

P: n/a
WMI is the way I would go, I haven't translated this to VB.NET, but it
should give you a start:

Function ChangeIpAddress(arrNewIPA, arrSubnetMask, arrGateway, strComputer)

Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colNetAdapters = objWMIService.ExecQuery ("Select * from
Win32_NetworkAdapterConfiguration " & "where IPEnabled=TRUE")
strIPAddress = arrNewIPA
strSubnetMask = arrSubnetMask
strGateway = arrGateway
strGatewayMetric = Array(1)

For Each objNetAdapter in colNetAdapters
errEnable = objNetAdapter.EnableStatic(strIPAddress, strSubnetMask)
errGateways = objNetAdapter.SetGateways(strGateway, strGatewaymetric)
Next

End Function

"Nijazi Halimaji" <sp***@gmx.net> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
Hi

In VB6 i changed the IP-Adress and Gateway of the computer by using API.
Is there an object available in .net for doing this?

Thanks alot

Nijazi Halimaji

Nov 21 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.