473,378 Members | 1,522 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

IP addresses

Hi,
I have an application that needs to change the IP address of the local
computer.
How can I do this?

Regards,
Mystique
Nov 17 '05 #1
5 3086
Mystique,

You will want to use the classes in the System.Management namespace to
get the instance of the Win32_NetworkAdapterConfiguration WMI class that
corresponds to the adapter. Once you have that, you can call the
EnableStatic method on the instance to set the IP address for the adapter.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Mystique" <mi***@softhome.net> wrote in message
news:Om**************@TK2MSFTNGP14.phx.gbl...
Hi,
I have an application that needs to change the IP address of the local
computer.
How can I do this?

Regards,
Mystique

Nov 17 '05 #2
Ok,
And how can make the application Obtain an IP automatically?

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in
message news:OX**************@TK2MSFTNGP15.phx.gbl...
Mystique,

You will want to use the classes in the System.Management namespace to
get the instance of the Win32_NetworkAdapterConfiguration WMI class that
corresponds to the adapter. Once you have that, you can call the
EnableStatic method on the instance to set the IP address for the adapter.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Mystique" <mi***@softhome.net> wrote in message
news:Om**************@TK2MSFTNGP14.phx.gbl...
Hi,
I have an application that needs to change the IP address of the local
computer.
How can I do this?

Regards,
Mystique


Nov 17 '05 #3
Hi Mystique

Maybe you find the code below useful. It shows your IP-address. I didn't try
EnableStatic because I didn't find it practical to run the risk corrupting
my machine...

Christiaan.

ManagementClass mc = new
ManagementClass("Win32_NetworkAdapterConfiguration ");
ManagementObjectCollection moc = mc.GetInstances();
foreach(ManagementObject mo in moc)
{
Console.WriteLine("Description: {0}", mo["Description"].ToString());
if((bool)mo["IPEnabled"] == true)
{

string[] IPAddresses=(string[]) mo["IPAddress"];
for (int i=0;i<IPAddresses.Length;i++)
{
Console.WriteLine("+-> IpAddress {0} is:
{1}.",i.ToString(),IPAddresses[i]);
}

Console.WriteLine("+-> MAC address: {0}", mo["MacAddress"].ToString());
}
mo.Dispose();
}

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in
message news:OX**************@TK2MSFTNGP15.phx.gbl...
Mystique,

You will want to use the classes in the System.Management namespace to
get the instance of the Win32_NetworkAdapterConfiguration WMI class that
corresponds to the adapter. Once you have that, you can call the
EnableStatic method on the instance to set the IP address for the adapter.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Mystique" <mi***@softhome.net> wrote in message
news:Om**************@TK2MSFTNGP14.phx.gbl...
Hi,
I have an application that needs to change the IP address of the local
computer.
How can I do this?

Regards,
Mystique


Nov 17 '05 #4
thanks Christiaan
I figured that out
But can u tell me how i can make the OS to get automatically IPs from the
DNS server?

Regards,
Mystique

"Christiaan Nijdam" <ac*************@yahoo.com> wrote in message
news:43********************@dreader2.news.tiscali. nl...
Hi Mystique

Maybe you find the code below useful. It shows your IP-address. I didn't try EnableStatic because I didn't find it practical to run the risk corrupting my machine...

Christiaan.

ManagementClass mc = new
ManagementClass("Win32_NetworkAdapterConfiguration ");
ManagementObjectCollection moc = mc.GetInstances();
foreach(ManagementObject mo in moc)
{
Console.WriteLine("Description: {0}", mo["Description"].ToString());
if((bool)mo["IPEnabled"] == true)
{

string[] IPAddresses=(string[]) mo["IPAddress"];
for (int i=0;i<IPAddresses.Length;i++)
{
Console.WriteLine("+-> IpAddress {0} is:
{1}.",i.ToString(),IPAddresses[i]);
}

Console.WriteLine("+-> MAC address: {0}", mo["MacAddress"].ToString()); }
mo.Dispose();
}

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in message news:OX**************@TK2MSFTNGP15.phx.gbl...
Mystique,

You will want to use the classes in the System.Management namespace to get the instance of the Win32_NetworkAdapterConfiguration WMI class that
corresponds to the adapter. Once you have that, you can call the
EnableStatic method on the instance to set the IP address for the adapter.
Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Mystique" <mi***@softhome.net> wrote in message
news:Om**************@TK2MSFTNGP14.phx.gbl...
Hi,
I have an application that needs to change the IP address of the local
computer.
How can I do this?

Regards,
Mystique



Nov 17 '05 #5
If an address is not static, it comes from a DHCP server on your network,
not from a DNS server. Calling EnableDHCP() on the network adapter will
probably do what you want. I didn't try it myself.

See: ms-help://MS.VSCC/MS.MSDNVS/wmisdk/r_32hard4_6oq6.htm


"Mystique" <mi***@softhome.net> wrote in message
news:OO**************@tk2msftngp13.phx.gbl...
thanks Christiaan
I figured that out
But can u tell me how i can make the OS to get automatically IPs from the
DNS server?

Regards,
Mystique

"Christiaan Nijdam" <ac*************@yahoo.com> wrote in message
news:43********************@dreader2.news.tiscali. nl...
Hi Mystique

Maybe you find the code below useful. It shows your IP-address. I didn't try
EnableStatic because I didn't find it practical to run the risk

corrupting
my machine...

Christiaan.

ManagementClass mc = new
ManagementClass("Win32_NetworkAdapterConfiguration ");
ManagementObjectCollection moc = mc.GetInstances();
foreach(ManagementObject mo in moc)
{
Console.WriteLine("Description: {0}", mo["Description"].ToString());
if((bool)mo["IPEnabled"] == true)
{

string[] IPAddresses=(string[]) mo["IPAddress"];
for (int i=0;i<IPAddresses.Length;i++)
{
Console.WriteLine("+-> IpAddress {0} is:
{1}.",i.ToString(),IPAddresses[i]);
}

Console.WriteLine("+-> MAC address: {0}",

mo["MacAddress"].ToString());
}
mo.Dispose();
}

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote

in
message news:OX**************@TK2MSFTNGP15.phx.gbl...
Mystique,

You will want to use the classes in the System.Management namespace to
get the instance of the Win32_NetworkAdapterConfiguration WMI class
that corresponds to the adapter. Once you have that, you can call the
EnableStatic method on the instance to set the IP address for the

adapter.
Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Mystique" <mi***@softhome.net> wrote in message
news:Om**************@TK2MSFTNGP14.phx.gbl...
> Hi,
> I have an application that needs to change the IP address of the local > computer.
> How can I do this?
>
> Regards,
> Mystique
>



Nov 17 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: dave | last post by:
Hello, I'm creating a site that has several contact email addresses. These are vlid addresses, i'm wondering if i can use php to alter these addresses so that spam harvesters can't get them, yet a...
2
by: Hoang | last post by:
anyone know of an algorithm to filter out real email addresses as opposed to computer generated email addresses? I have been going through past email archives in order to find friends email...
17
by: Andrew McLean | last post by:
I have a problem that is suspect isn't unusual and I'm looking to see if there is any code available to help. I've Googled without success. Basically, I have two databases containing lists of...
3
by: Grytpype-Thynne | last post by:
Can anyone point me in the direction of a cross browser way of displaying two addresses side by side after some preliminary text? I have tried a containing box and floating two further boxes...
2
by: Not Me | last post by:
Hi, I've been having this problem for a while now and seem to be getting closer to a solution but it's still not perfect. I have a table of addresses, people (refno's) may have more than one...
6
by: DebbieG | last post by:
I am creating a database for a small department in a university. Each student in their database can have 2 mailing addresses. They wanted mailing labels pulling just the 1st address. No problem....
2
by: (Pete Cresswell) | last post by:
For better or worse, I have chosen to implement mailing addresses in a particular application as a separate table. One Person ==> Many Addresses. It is a database for managing school reunions...
11
by: Paul Fi | last post by:
How can i determine IP Address of my machine at runtime without providing any information like HostName? *** Sent via Developersdex http://www.developersdex.com *** Don't just participate in...
1
by: Lyle Fairfield | last post by:
Option Explicit ' requires VBScript to be installed ' (maybe don't give this to your sugnificant other as ' it gets deleted addresses as well as current) ' obvious fixups needed '1. how get...
4
by: =?Utf-8?B?U2VyZ2Vp?= | last post by:
Dear staff Can I get your assistance with \3GB (LARGEADDRESSAWARE) switch in mixed mode process built by VS 2008, please? I have a mixed mode application: C# GUI calling native C++ DLL through...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.