找回密码
 加入
搜索
查看: 2025|回复: 3

[效率算法] 关于dword值的转换(IP地址转换成dword值)

[复制链接]
发表于 2010-11-24 11:59:14 | 显示全部楼层 |阅读模式
本帖最后由 newmin 于 2010-11-24 13:22 编辑

百度了下 DWORD 是表示 32bit 无符号整数,但是用AU3怎么把指定字符串转换成dword值呢?
比如 我要把一个IP地址转换成dword值。
 楼主| 发表于 2010-11-25 12:00:51 | 显示全部楼层
没人对这问题感兴趣吗?
 楼主| 发表于 2010-11-25 17:54:55 | 显示全部楼层
知道了。原来就是把符号去掉,再转换成16进制。

谁提供下10转16进制的源码,我好不容易拼凑出的10转16进制太烂了。
发表于 2010-11-25 21:24:35 | 显示全部楼层
$sIpAddress = "244.115.158.153"
$aIPAddress = StringSplit($sIpAddress, ".", 2)

$iIPAddress = BitOR($aIPAddress[0], BitShift($aIPAddress[1], -8), _
        BitShift($aIPAddress[2], -16), BitShift($aIPAddress[3], -24))
                        
MsgBox(0, "long", $iIPAddress)

$iDword = $iIPAddress
$sIpAddress = StringFormat("%d.%d.%d.%d", _
                        BitAnd($iDword, 0xFF), _
                        BitAnd(BitShift($iDword, 8), 0xFF), _
                        BitAnd(BitShift($iDword, 16), 0xFF), _
                        BitAnd(BitShift($iDword, 24), 0xFF))

MsgBox(0, "string", $sIpAddress)
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-5-16 04:36 , Processed in 0.077362 second(s), 23 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表