Inno Setup Detects Windows Firewall Status

I need to determine the status of the Windows firewall (that is, whether it is turned on or not) to display a message warning that the firewall rule can be configured to allow incoming connections on certain ports when the firewall is turned on, but not when it is not. Sample code below:

[Code]
//Check if Windows Firewall is enabled
function IsWindowsFirewallEnabled(): Boolean;
begin
//Method required here
  Result := True;
end;

function NextButtonClick(CurPageID: Integer): Boolean;
begin
//Display a warning message on a Server install if Windows Firewall is enabled
  if CurPageID = wpSelectComponents and IsComponentSelected('Server') and IsWindowsFirewallEnabled then
    begin
      MsgBox('Windows Firewall is currently enabled.' + #13#10 + #13#10 +
        'You may need to enable inbound connections on ports 2638, 445 and 7.'
        mbInformation, MB_OK);
      Result := True;
    end;
end;

I need a method for a function IsWindowsFirewallEnabled. One of the methods that I read about, and, ironically, now more or less suggested below, while I was in the middle of updating the question with this information, in any case, it seems to read the value EnableFirewallfrom the registry:

//Check if Windows Firewall is enabled
function IsWindowsFirewallEnabled(): Boolean;
var
  crdFirewallState: Cardinal;
begin
  RegQueryDwordValue(HKLM, 'SYSTEM\CurrentControlSet\Services\SharedAccess\Parameters\FirewallPolicy\StandardProfile',
    'EnableFirewall', crdFirewallState);
  if crdFirewallState = 1 then
    Result := True;
end;

, , , , ( , ).

, Windows XP, Server 2003, Windows Vista Server 2008 .

, ?

+1
1

, , , Innosetup.

var
  Country: String;
begin
  if RegQueryStringValue(HKEY_CURRENT_USER, 'Control Panel\International',
     'sCountry', Country) then
  begin
    // Successfully read the value
    MsgBox('Your country: ' + Country, mbInformation, MB_OK);
  end;
end;

http://www.jrsoftware.org/ishelp/index.php?topic=isxfunc_regquerystringvalue

:

: HKEY_LOCAL_MACHINE\SOFTWARE\\Microsoft\WindowsFirewall\DomainProfile : : EnableFirewall : DWORD ( DWORD) Enabled : 0 : 1

+1

Source: https://habr.com/ru/post/1606463/


All Articles