Solved

flushdns

Posted on 2011-09-26
2
1,264 Views
Last Modified: 2016-10-03
I need to clear the DNS cache and I don't want to use "ipconfig /flushdns".
It looks like dnsapi.dll can be used for that but I can't find any Delphi code example.
Below is a C language example.
I'd like to have the same function for Delphi 7.
Thanks.

BOOL DnsFlushResolverCache()
{
   BOOL (WINAPI *DoDnsFlushResolverCache)();
   *(FARPROC *)&DoDnsFlushResolverCache = GetProcAddress(LoadLibrary("dnsapi.dll"), "DnsFlushResolverCache");
   if(!DoDnsFlushResolverCache) return FALSE;
   return DoDnsFlushResolverCache();
}

Open in new window

0
Comment
Question by:3axap
2 Comments
 
LVL 5

Assisted Solution

by:DerZauberer
DerZauberer earned 200 total points
ID: 36598107
The above should be the declaration.

unit

...

interface

...

implementation

{ declaration }
Function DnsFlushResolverCache: DWord; stdcall; external 'dnsapi.dll';

...

{ call it }
procedure CallIt;
begin
  { call it, ignore return code }
  DnsFlushResolverCache;
end;
0
 
LVL 4

Accepted Solution

by:
rotem156 earned 300 total points
ID: 36598286
You're welcome.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
This video discusses moving either the default database or any database to a new volume.
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now