security - Inno Setup detect Windows Firewall state -


i need detect windows firewall state (i.e. whether enabled or not) in order display message warning firewall rule may need configured allow inbound connections on specific ports when firewall enabled, not when isn't. see below code example:

[code] //check if windows firewall enabled function iswindowsfirewallenabled(): boolean; begin //method required here   result := true; end;  function nextbuttonclick(curpageid: integer): boolean; begin //display warning message on server install if windows firewall enabled   if curpageid = wpselectcomponents , iscomponentselected('server') , iswindowsfirewallenabled     begin       msgbox('windows firewall enabled.' + #13#10 + #13#10 +         'you may need enable inbound connections on ports 2638, 445 , 7.'         mbinformation, mb_ok);       result := true;     end; end; 

what need method iswindowsfirewallenabled function. 1 way have read about, , ironically has more or less been suggested below whilst in middle of updating question information anyway, appear reading enablefirewall value registry:

//check if windows firewall enabled function iswindowsfirewallenabled(): boolean; var   crdfirewallstate: cardinal; begin   regquerydwordvalue(hklm, 'system\currentcontrolset\services\sharedaccess\parameters\firewallpolicy\standardprofile',     'enablefirewall', crdfirewallstate);   if crdfirewallstate = 1     result := true; end; 

however, not convinced method registry values profiles show enabled on work pc, looking in control panel domain profile shows disabled (i assume related group policy).

note, needs work both windows xp , server 2003, , windows vista , server 2008 , above.

therefore, what's reliable or recommended way this?

you need determine registry entry , query in manner similar using innosetup's registry query ability.

var   country: string; begin   if regquerystringvalue(hkey_current_user, 'control panel\international',      'scountry', country)   begin     // read value     msgbox('your country: ' + country, mbinformation, mb_ok);   end; end; 

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

allegedly information registry key:

path: hkey_local_machine\software\policies\microsoft\windowsfirewall\domainprofile location: local machine value name: enablefirewall data type: dword (dword value) enabled value: 0 disabled value: 1


Comments

Popular posts from this blog

php - Admin SDK -- get information about the group -

dns - How To Use Custom Nameserver On Free Cloudflare? -

Python Error - TypeError: input expected at most 1 arguments, got 3 -