My C#
服务需要定期轮询nslookup host server
。目前它产生了一个Process
执行批处理脚本。由于性能原因,我正在考虑使用一些进行此检查API
。但问题是,例如,使用System.Net.Dns.GetHostAddresses
我只能效仿nslookup host
检查,但没有nslookup host server
(没有秒参数)。
我看过很多类似的问题,但似乎没有一个能解决我的问题。
有什么办法可以执行nslookup host server
in C#
不使用一些重型第三方库?
问题解决了!
http://msdn.microsoft.com/en-us/library/ms682016(VS.85).aspx http://msdn.microsoft.com/en-us/library/ms682016(VS.85).aspx
See "很好的例子在这里“ 部分
[DllImport("dnsapi", EntryPoint="DnsQuery_W", CharSet=CharSet.Unicode, SetLastError=true, ExactSpelling=true)]
private static extern int DnsQuery([MarshalAs(UnmanagedType.VBByRefStr)]ref string pszName, QueryTypes wType, QueryOptions options, int aipServers, ref IntPtr ppQueryResults, int pReserved);
[DllImport("dnsapi", CharSet=CharSet.Auto, SetLastError=true)]
private static extern void DnsRecordListFree(IntPtr pRecordList, int FreeType);
...
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)