Ureader.com  
Microsoft software help and Community
   home   |   control panel login   |   archive   |  
 
DotNet
acad.assignment.mngr
academic
adonet
aspnet
aspnet.announcements
aspnet.build.controls
aspnet.caching
aspnet.datagridcontrol
aspnet.mobile
aspnet.security
aspnet.webcontrols
aspnet.webservices
clr
compactframework
component_services
datatools
distributed_apps
drawing
faqs
framework
framework.wmi
general
internationalization
interop
languages.csharp
languages.jscript
languages.vb
languages.vb.controls
languages.vb.data
languages.vb.upgrade
languages.vc
languages.vc.libraries
myservices
odbcnet
performance
remoting
scripting
sdk
security
setup
vjsharp
vsa
webservi.enhancements
webservices
windowsforms
windowsforms.controls
winforms.databinding
winforms.designtime
xml
  
 
date: Tue, 22 Jul 2008 14:58:10 -0700 (PDT),    group: microsoft.public.dotnet.languages.csharp        back       


Adding an IP address to a network card   
I'm trying to add an IP address to a pc's network card.  In C++ I used
the IPHlpApi.lib's function AddIPAddress.  Is there a built in way to
add an IP Address in C#?

Thanks in advance...
date: Tue, 22 Jul 2008 14:58:10 -0700 (PDT)   author:   tag

Re: Adding an IP address to a network card   
Hello,

don't think there is a built in way but how about
[DllImport("iphlpapi.dll", SetLastError=true)]
static extern int AddIPAddress(int Address, int IpMask, int IfIndex, out 
IntPtr NTEContext, out IntPtr NTEInstance );

if unmanaged is an option then this will do the trick...

look on pinvoke.net for usage.

Leo

"tag"  wrote in message 
news:3bf341e1-952c-4bab-b4b9-894bc3d4b32a@34g2000hsf.googlegroups.com...
> I'm trying to add an IP address to a pc's network card.  In C++ I used
> the IPHlpApi.lib's function AddIPAddress.  Is there a built in way to
> add an IP Address in C#?
>
> Thanks in advance...
date: Wed, 23 Jul 2008 10:37:06 +0100   author:   Leo Seccia

Re: Adding an IP address to a network card   
"Leo Seccia" wrote:

> Hello,
> 
> don't think there is a built in way but how about
> [DllImport("iphlpapi.dll", SetLastError=true)]
> static extern int AddIPAddress(int Address, int IpMask, int IfIndex, out 
> IntPtr NTEContext, out IntPtr NTEInstance );
> 
> if unmanaged is an option then this will do the trick...
> 
> look on pinvoke.net for usage.
> 
> Leo
> 
> "tag"  wrote in message 
> news:3bf341e1-952c-4bab-b4b9-894bc3d4b32a@34g2000hsf.googlegroups.com...
> > I'm trying to add an IP address to a pc's network card.  In C++ I used
> > the IPHlpApi.lib's function AddIPAddress.  Is there a built in way to
> > add an IP Address in C#?
> >
> > Thanks in advance... 
> 
> 


There is also WMI and Win32_NetworkAdapterConfiguration class.

-- 
urkec
date: Wed, 23 Jul 2008 07:04:09 -0700   author:   urkec

Re: Adding an IP address to a network card   
On Jul 23, 7:04 am, urkec  wrote:
> "Leo Seccia" wrote:
> > Hello,
>
> > don't think there is a built in way but how about
> > [DllImport("iphlpapi.dll", SetLastError=true)]
> > static extern int AddIPAddress(int Address, int IpMask, int IfIndex, out
> > IntPtr NTEContext, out IntPtr NTEInstance );
>
> > if unmanaged is an option then this will do the trick...
>
> > look on pinvoke.net for usage.
>
> > Leo
>
> > "tag"  wrote in message
> >news:3bf341e1-952c-4bab-b4b9-894bc3d4b32a@34g2000hsf.googlegroups.com...
> > > I'm trying to add an IP address to a pc's network card.  In C++ I used
> > > the IPHlpApi.lib's function AddIPAddress.  Is there a built in way to
> > > add an IP Address inC#?
>
> > > Thanks in advance...
>
> There is also WMI and Win32_NetworkAdapterConfiguration class.
>
> --
> urkec

Thanks for both of your suggestions.  I used iphlpapi.dll and it works
okay, I noticed that I have to call it early in my program, or the NIC
card isn't changed before the socket is created...
date: Thu, 31 Jul 2008 09:25:19 -0700 (PDT)   author:   tag

Google
 
Web ureader.com


    COPYRIGHT 2007, YARDI TECHNOLOGY LIMITED, ALL RIGHT RESERVE  |   contact us