In my application, I broadcast events over the network with standard messages for other application instances, in order to synchronize.
I want to add my app to the authorized list of the firewall, and I do this with:
NetFwTypeLib API DLL
If I do this in every run, it will be added to the list several times.
My question is: How can I retrieve the list of authorized applications for checking if the application was added before, and then not add it to the list?
Based on your comments, it sounds like you want something like this:
Type NetFwMgrType = Type.GetTypeFromProgID("HNetCfg.FwMgr", false);
INetFwMgr mgr = (INetFwMgr)Activator.CreateInstance(NetFwMgrType);
applications =
(INetFwAuthorizedApplications)mgr.LocalPolicy.CurrentProfile.AuthorizedApplications;
For older OS's, look here for complete documentation:
http://technet.microsoft.com/en-us/library/cc737845%28WS.10%29.aspx
http://msdn.microsoft.com/en-us/library/windows/desktop/aa365101%28v=vs.85%29.aspx
For newer OS's (Vista and higher), use Windows Firewall with Advanced Security instead.