Changing Windows 95 IP address
Keywords: IP address getter DEFINITIVE IP ADDRESS
Question:
We need an automated way of changing an IP address in Windows 95. We are moving a bunch of users from an IP address of 131.87.13.xxx to an IP address of 131.87.22.xxx. We want to preserve the .xxx the same as their previous IP address.I know this will involve editing the registry. I am kind of short on time and would appreciate any code you can pull off the top of your head.
Answer:
A quick stab at it.....for xx=0 to 9 netnum=strfixleft(xx,0,4) key ="System\CurrentControlSet\Services\Class\NetTrans\%netnum%[IpAddress]" if regexistvalue(@regmachine,key) ipaddr=RegQueryValue(@regmachine,key) ipaddr =strreplace(ipaddr,"131.87.13.","131.87.22.") RegSetValue(@regmachine,key,ipaddr) endif next
The Definitive Method to Change IP Address (DllCall to WSOCK32.DLL Method):
NB: Use this method to get the primary IP address (as opposed to, for example, the dial up address).;Script by Len Sher May 11, 1998 / Modified by Marty - July 17, 1998 ;SHER_LI@exchange.phs.com ;This code fragment was written to obtain the ip address of a workstation ;from the winsock dll (wsock32.dll). Hostent = BinaryAlloc(1000) if Hostent == 0 then Message("Error", "Hostent Allocation Failed") Return endif binaryEodSet(Hostent, 16) Wsadata = BinaryAlloc(1000) if Wsadata == 0 then Message("Error", "Wsadata Allocation Failed") Return endif BinaryEodSet(Wsadata, 14) Hostname = BinaryAlloc(1000) if Hostname == 0 then Message("Error", "Hostname Allocation Failed") Return endif BinaryEodSet(Hostname, 256) length=256 ver=257 dllhandle=0 dllhandle=DllLoad(strcat(dirwindows(1), "wsock32.dll")) ret=DllCall(dllhandle, lpstr:"WSAStartup", long:ver, lpbinary:Wsadata) if ret <> "WSAStartup" then Message("Error", "Winsock dll (wsock32.dll) not responding") endif wVersion=BinaryPeek2(Wsadata, 0) ;Message("Version", wVersion) ret=DllCall(dllhandle, lpstr:"gethostname", lpbinary:Hostname, long:length) if ret == -1 then Message("Error", "Windows Sockets Error") Return endif ;Message("the computer is",BinaryPeekStr(Hostname,0,length)) hostent_addr=DllCall(dllhandle, long:"gethostbyname", lpbinary:Hostname) ;Message("hostent_addr", hostent_addr) hName=IntControl(32,hostent_addr,"LONG",0,0) ;Message("hName Pointer", hName) hostent_addr=hostent_addr + 4 hAliases=IntControl(32,hostent_addr,"LONG",0,0) ;Message("hAliases Pointer", hAliases) hostent_addr=hostent_addr + 4 hAddrType=IntControl(32,hostent_addr,"LONG",0,0) ;Message("hAddrType Pointer", hAddrType) hostent_addr=hostent_addr + 4 ;hostent_addr=hostent_addr + 12 ;ADD 12 TO POINT TO hAddrList ;Message("hostent_addr Incremented", hostent_addr) hAddrList=IntControl(32,hostent_addr,"LONG",0,0) ;Message("the hAddrList pointer is ",hAddrList) IpAddress=IntControl(32,hAddrList,"LONG",0,0) ;Message("the IpAddress pointer is ",IpAddress) ip1=IntControl(32,IpAddress,"BYTE",0,0) IpAddress=IpAddress + 1 ip2=IntControl(32,IpAddress,"BYTE",0,0) IpAddress=IpAddress + 1 ip3=IntControl(32,IpAddress,"BYTE",0,0) IpAddress=IpAddress + 1 ip4=IntControl(32,IpAddress,"BYTE",0,0) if ip1 < 0 ip1 = ip1 + 256 endif if ip2 < 0 ip2 = ip2 + 256 endif if ip3 < 0 ip3 = ip3 + 256 endif if ip4 < 0 ip4 = ip4 + 256 endif ret=DllCall(dllhandle, lpstr:"WSACleanup") if ret == -1 then Message("Error", "Windows Sockets Error") Return endif Message("the Ip Address is", strcat(ip1,".",ip2,".",ip3,".",ip4)) DllFree(dllhandle) BinaryFree(Hostent) BinaryFree(Wsadata) BinaryFree(Hostname)
Article ID: W13134Filename: Change IP Address Automatically.txt