jaenster Posted September 22, 2007 Share Posted September 22, 2007 How to know the submask ipaddress in autoit? The most of the time its 255.255.255.0 But it can be different, My question: How to know your broadcast addres? Why i want? With the submask i can calucate the broadcast address for my udp broadcast chat system idea. -jaenster -jaenster Link to comment Share on other sites More sharing options...
frostfel Posted September 22, 2007 Share Posted September 22, 2007 (edited) How to know the submask ipaddress in autoit?The most of the time its 255.255.255.0But it can be different, My question: How to know your broadcast addres?Why i want?With the submask i can calucate the broadcast address for my udp broadcast chat system idea.-jaensterwow this took a while for me to findBut 1st goto "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces\" and find the interface number of your network card there all diffrent$Submask = RegRead("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces\{YOUR NETWORKD CARD INTERFACE}", "DhcpSubnetMask") MsgBox(0, "Test", "Your Submask is: "&$Submask) Edited September 22, 2007 by frostfel Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted September 22, 2007 Moderators Share Posted September 22, 2007 Could have tried something like: Func _SubnetMask() Local $iPID, $sHold, $aSRE $iPID = Run(@ComSpec & " /c ipconfig", "", @SW_HIDE, 2) While 1 $sHold &= StdoutRead($iPID) If @error Then ExitLoop If StringInStr($sHold, "Subnet Mask") Then $aSRE = StringRegExp($sHold, 'Subnet Mask [\.| ]+: (.*?)\r', 1) If IsArray($aSRE) Then Return $aSRE[0] EndIf WEnd Return SetError(1, 0, 0) EndFuncAs well I suppose. Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted September 22, 2007 Moderators Share Posted September 22, 2007 This one makes more sense. Func _SubnetMask($strIP = @IPAddress1) Local $oWMISvc = ObjGet("winmgmts:\\" & $strIP & "\root\cimv2") Local $colAll = $oWMISvc.ExecQuery("SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled = True") Local $oAll For $oAll In $colAll For $iCC = 0 To UBound($oAll.IPSubnet) If StringRegExp($oAll.IPSubnet($iCC), "255.\d+\.\d+\.\d+") Then Return $oAll.IPSubnet($iCC) Next Next Return SetError(1, 0, 0) EndFunc Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
Nahuel Posted September 22, 2007 Share Posted September 22, 2007 That one^ works but it's very slow. Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted September 22, 2007 Moderators Share Posted September 22, 2007 That one^ works but it's very slow.It was kind of slow... hows this one for speed?Func _SubnetMask($strIP = @IPAddress1) Local $strEnumKey, $nEnum Local $strKey = "HKLM\SYSTEM\CurrentControlSet\" & _ "Services\Tcpip\Parameters\Interfaces\" While 1 $nEnum += 1 $strEnumKey = RegEnumKey($strKey, $nEnum) If @error <> 0 Then ExitLoop If RegRead($strKey & $strEnumKey, "DhcpIPAddress") = $strIP Then Return RegRead($strKey & $strEnumKey, "DhcpSubnetMask") EndIf WEnd Return SetError(1, 0, 0) EndFunc Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
Nahuel Posted September 22, 2007 Share Posted September 22, 2007 Perfect!! I needed this too. Link to comment Share on other sites More sharing options...
jaenster Posted September 24, 2007 Author Share Posted September 24, 2007 Thanks~!!!! -jaenster Link to comment Share on other sites More sharing options...
Alpinestar Posted February 27, 2008 Share Posted February 27, 2008 Thanks real handy Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now