Jump to content
Sign in to follow this  
txj

How to set IP address

Recommended Posts

txj

I want to set my host's IP address, who can tell me which Win32API can do it.

Share this post


Link to post
Share on other sites
MrMitchell

You can try running a cmd prompt and using it to execute a string you built...

$cmd='netsh interface ip set address name="Local Area Connection" static 192.168.1.50 255.255.0.0 192.168.1.1 1'
Run(@ComSpec & " /c " & $cmd, "", @SW_SHOW)

Share this post


Link to post
Share on other sites
txj

You can try running a cmd prompt and using it to execute a string you built...

$cmd='netsh interface ip set address name="Local Area Connection" static 192.168.1.50 255.255.0.0 192.168.1.1 1'
Run(@ComSpec & " /c " & $cmd, "", @SW_SHOW)
I tested this code, but run time is between 4~22 seconds in my 2 computers which runs Win2K, other is WinXP, too slow, so I hope to call Win32API to set my host's IP address.

Share this post


Link to post
Share on other sites
MrMitchell

I didn't have a chance to test it, so I'm surprised it worked at all...at least on the first shot anyway. Good luck with your Win API... can you post it if you get it figured out?

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.