public void run() { DNS_CACHE_ENTRY entry = new DNS_CACHE_ENTRY(); entry.wDataLength = 1024; bool res = DnsGetCacheDataTable(ref entry); entry = (DNS_CACHE_ENTRY)Marshal.PtrToStructure(entry.pNext, typeof(DNS_CACHE_ENTRY)); res = true; while (res == true) { Console.WriteLine("DNS Entry: " + Marshal.PtrToStringAuto(entry.recName)); try { entry = (DNS_CACHE_ENTRY)Marshal.PtrToStructure(entry.pNext, typeof(DNS_CACHE_ENTRY)); } catch { res = false; } } Console.ForegroundColor = ConsoleColor.Yellow; Console.WriteLine("================================================================="); Console.ForegroundColor = ConsoleColor.White; Console.WriteLine("DONE!"); Console.ForegroundColor = ConsoleColor.Yellow; Console.WriteLine("================================================================="); Console.ForegroundColor = ConsoleColor.White; }
public static extern bool DnsGetCacheDataTable(ref DNS_CACHE_ENTRY entry);