Saturday, September 12, 2009

Shutup Windows Firewall

When you start a HTTP or TCP server and you have Windows Firewall active you've noticed that a window will appear "Windows Security Alert" if your customer doesn't have too much Windows knowledge then he freaks out "What is that, do I have a virus, your program doesn't work!".
Here's something to bypass this warning:
 - Put a TTimer on a form
 - OnTimer event Copy-Paste this code
const
  CWINDOWSECURITYALER = 'Windows Security Alert';
  CBTNUNLOCK = 'Unblock';
var
  hwndAlert: HWND;
begin
  hwndAlert := FindWindow(nil, CWINDOWSECURITYALER);
  if hwndAlert <> 0 then
    WindowBtnClick(hwndAlert, CBTNUNLOCK);
end;

You can get WindowBtnClick procedure code from my older post Click a window's button.
Change timer's interval to 200 or 500.
Before starting a server or anything that triggers a "Windows Security Alert" window enable timer and after that disable it.
Tested only under Windows XP, should/might work under Windows Vista and/or Windows 7, please let me know if you test this under any other OS version than XP.

No comments:

Post a Comment

Blogroll(General programming and Delphi feeds)