467,114 Members | 1,273 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,114 developers. It's quick & easy.

Changing IP-Addres and Default Gateway

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
  • viewed: 4916
Share:
2 Replies
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
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.

Similar topics

6 posts views Thread by Kris | last post: by
1 post views Thread by steven virnig | last post: by
reply views Thread by Andrea Pagliano | last post: by
3 posts views Thread by amisol@gmail.com | last post: by
3 posts views Thread by cyberco | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.