开发者

How to detect that Windows Firewall is asking user for permission

We're working on an application that listens on some ports. We really want to avoid using a proper installer, so we can't open the firewall at that point.

First time the application runs, Windows pops up a dialog, asking the user for permission. At this point, we want to delay execution until the user has clicked yes (or no, for that matter).

At present we use something like:

while(FindWindow("Windows Security Alert")) {
    Sleep(1000);
}

..which works, but isn't rock solid. As far as i can tell, the firewall api doesn't offer this information.

Bonus question: Is there also a way to detect 开发者_运维技巧whether the user clicked yes or no?


Here you can find some code on how to open the filewall port yourself in C# code http://www.shafqatahmed.com/2008/01/controlling-win.html Of course your app must be running elevated in order to do this.

There are several installers on the web too which offer this functionality. For example (unfortunately not open source): uTorrent's installer.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜