DnsFlushResolverCache 清除windows DNS缓存
效果等同于ipconfig /flushdns 命令。
DnsFlushResolverCache 函数是在Dnsapi.dll导出,该函数没有任何参数。MSDN中找不到他,看来是个Undocumented函数,函数原型:
BOOL WINAPI DnsFlushResolverCache(VOID);
BOOL __stdcall DnsFlushResolverCache() { BOOL bRet = FALSE; typedef BOOL (WINAPI *PfuncDnsFlushResolverCache)(VOID); HMODULE hDnsModule = LoadLibrary( _T("dnsapi.dll") ); if ( hDnsModule != NULL ) { PfuncDnsFlushResolverCache pFlushFun = GetProcAddress( hDnsModule, "DnsFlushResolverCache" ); if ( pFlushFun != NULL ) { pFlushFun(); bRet = TRUE; } FreeLibrary( hDnsModule ); } return bRet; }
vb6 申明:
Private Declare Function DnsFlushResolverCache Lib "dnsapi.dll" () As Long