Solved

flushdns

Posted on 2011-09-26
2
1,268 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
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…
I designed this idea while studying technology in the classroom.  This is a semester long project.  Students are asked to take photographs on a specific topic which they find meaningful, it can be a place or situation such as travel or homelessness.…
This is a video that shows how the OnPage alerts system integrates into ConnectWise, how a trigger is set, how a page is sent via the trigger, and how the SENT, DELIVERED, READ & REPLIED receipts get entered into the internal tab of the ConnectWise …

914 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

14 Experts available now in Live!

Get 1:1 Help Now