Click to See Complete Forum and Search --> : Get/Set subnet mask


Mohana Deshmukh
January 10th, 2000, 01:09 PM
I would like to get/set the IP address and subnet mask in a visual basic application. what is the API that I can use? I would prefer to use something that will work without much change across all windows platforms (atleast WIN98/WIN95)

Any help is appreciated

Corn
November 6th, 2002, 03:27 AM
Hi!! you can use the DhcpNotifyConfigChange in dhcpcsvc.dll,

I haven’t got it to work. I always get the return value of 2 which is an error code the right code is 0 if the command executed successfully.

Please msg me if you get it to work!!

here's the proto:

BOOL DhcpNotifyConfigChange(
LPWSTR lpwszServerName, // NULL for local machine
LPWSTR lpwszAdapterName, // see below
BOOL fNewIpAddress, // TRUE if IP address modified
DWORD dwIpIndex, // IP address index (0 based)
DWORD dwIpAddress, // IP address to set (network order)
DWORD dwSubNetMask, // Associated subnet mask (network order)
int nDhcpAction ); // 0:don't modify/1:enable/2:disable DHCP

o On NT 4.0, lpwszAdapterName is the "ServiceName" registry value under
HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\NetworkCards\<"n"
network card index> for your adapter.

o On W2K, lpwszAdapterName is the "NetCfgInstanceId" registry value
under
HKLM\System\CurrentControlSet\Control\Class\{4d36e972-e325-11ce-bfc1-080
02be10318}\<"000n" network card index> for your adapter.

Changes made through DhcpNotifyConfigChange are temporary (they will
vanish with the next reboot): you will have to set appropriate values in
the registry to make them permanent.