开发者

ShellExecute blocks (never returns) when firewall denies internet access

I've been开发者_StackOverflow社区 using ShellExecute to open URLs in a browser, invoked from a modal windows' code, like this:

procedure TfmAbout1.BtnHomePageClick(Sender: TObject);
begin
   inherited;
   if ConnectedToWeb then
    ShellExecute(Handle, 'open', URL_PRODUCT_HOMEPAGE, nil, nil, SW_SHOWNORMAL);
end;

But on machines with the Zone Alarm firewall, the user may get a pop-up prompt to allow or deny my application access to the Internet. When the user clicks "Deny", then ShellExecute never returns... my application is then hung & the process has to be shut down externally (i.e., from Task Manager).

What can I do to either anticipate or prevent this? I need something like a ShellExecute that is non-blocking in this situation.

I'd appreciate any ideas.


So you want to work around a bug in Zone Alarm?

I'd probably check for the Zone Alarm version, and depending on it, have a small 'bootstrap' program perform the ShellExecute on my behalf. That would only hang the small bootstrap program.

You could kill that bootstrap program (since your parent process is the owner) if it hasn't returned after a time out (15 or 30 seconds would do).

You could even warn the user that is has a buggy version of Zone Alarm :)

Edit: Note: I think killing a process is safer than killing a thread.


Well, run ShellExecute in a thread. In some time you could see if it completed or not. If not, you could just terminate it.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜