for i, v in GetDnsAddress()
MsgBox % v
; 获取本地计算机使用的 DNS 服务器列表。
GetDnsAddress() {
if (DllCall("iphlpapi.dll\GetNetworkParams", "ptr", 0, "uint*", size) = 111) && !(VarSetCapacity(buf, size, 0))
throw Exception("Memory allocation failed for FIXED_INFO struct", -1)
if (DllCall("iphlpapi.dll\GetNetworkParams", "ptr", &buf, "uint*", size) != 0)
throw Exception("GetNetworkParams failed with error: " A_LastError, -1)
addr := &buf, DNS_SERVERS := []
DNS_SERVERS[1] := StrGet(addr + 264 + (A_PtrSize * 2), "cp0")
ptr := NumGet(addr+0, 264 + A_PtrSize, "uptr")
while (ptr) {
DNS_SERVERS[A_Index + 1] := StrGet(ptr+0 + A_PtrSize, "cp0")
ptr := NumGet(ptr+0, "uptr")
}
return DNS_SERVERS
}
声明:站内资源为整理优化好的代码上传分享与学习研究,如果是开源代码基本都会标明出处,方便大家扩展学习路径。请不要恶意搬运,破坏站长辛苦整理维护的劳动成果。本站为爱好者分享站点,所有内容不作为商业行为。如若本站上传内容侵犯了原著者的合法权益,请联系我们进行删除下架。

评论(0)