public bool IsApplicationEnabled(string applicationFileNameWithPath) { DoDisposeCheck(); DoInitializationCheck(); if (string.IsNullOrEmpty(applicationFileNameWithPath)) { ThrowHelper.ThrowArgumentNullException("applicationFileNameWithPath"); } INetFwAuthorizedApplications firewallApps = mFirewallProfile.AuthorizedApplications; if (firewallApps == null) { throw new FirewallException("Failed to get authorized applications."); } bool result = false; try { INetFwAuthorizedApplication firewallApp = firewallApps.Item(applicationFileNameWithPath); // If FAILED, the application is not in the collection list if (firewallApp != null) { result = firewallApp.Enabled; } } catch (Exception) { } return(result); }
public FW_ERROR_CODE IsAppEnabled(string strProcessImageFileName, ref bool bEnable) { if (m_FirewallProfile == null) { return(FW_ERROR_CODE.FW_ERR_INITIALIZED); } if (strProcessImageFileName.Length == 0) { return(FW_ERROR_CODE.FW_ERR_INVALID_ARG); } INetFwAuthorizedApplications FWApps = m_FirewallProfile.AuthorizedApplications; if (FWApps == null) { return(FW_ERROR_CODE.FW_ERR_AUTH_APPLICATIONS); } try { INetFwAuthorizedApplication FWApp = FWApps.Item(strProcessImageFileName); // If FAILED, the appliacation is not in the collection list if (FWApp == null) { return(FW_ERROR_CODE.FW_ERR_APPLICATION_ITEM); } bEnable = FWApp.Enabled; } catch (FileNotFoundException) { bEnable = false; } return(FW_ERROR_CODE.FW_NOERROR); }
public FwErrorCode IsAppEnabled(string strProcessImageFileName, ref bool bEnable) { if (_mFirewallProfile == null) { return(FwErrorCode.FwErrInitialized); } if (strProcessImageFileName.Length == 0) { return(FwErrorCode.FwErrInvalidArg); } INetFwAuthorizedApplications fwApps = _mFirewallProfile.AuthorizedApplications; if (fwApps == null) { return(FwErrorCode.FwErrAuthApplications); } try { INetFwAuthorizedApplication fwApp = fwApps.Item(strProcessImageFileName); // If FAILED, the appliacation is not in the collection list if (fwApp == null) { return(FwErrorCode.FwErrApplicationItem); } bEnable = fwApp.Enabled; } catch (System.IO.FileNotFoundException) { bEnable = false; } return(FwErrorCode.FwNoerror); }