有没有办法从 C# WPF 应用程序中刷新 DNS 缓存?该应用程序将在 XP、Vista 或 Windows 7 上运行。
最佳答案
您可以使用 Microsoft 的“dnsapi.dll”中的函数。这将允许您完全以编程方式执行此操作:
using System.Runtime.InteropServices;
[DllImport("dnsapi.dll",EntryPoint="DnsFlushResolverCache")]
private static extern UInt32 DnsFlushResolverCache ();
public static void FlushMyCache() //This can be named whatever name you want and is the function you will call
{
UInt32 result = DnsFlushResolverCache();
}
我已经测试过了,效果很好。
关于c# - 有没有办法从 C# WPF 应用程序中刷新 DNS 缓存? (在 XP、Vista、Win7 上),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3498337/