Local $oFireWall = ObjCreate("HNetCfg.FwPolicy2")
ConsoleWrite($oFireWall.CurrentProfileTypes & @CRLF)
ConsoleWrite($oFireWall.FirewallEnabled($oFireWall.CurrentProfileTypes) & @CRLF)
Regarding Windows Firewall information detection, the results of the above code are correct, but the results of the following code are wrong. What‘s the problem with the following code?
Local Const $CLSID_NetFwPolicy2 = "{E2B3C97F-6AE1-41AC-817A-F6F92166D7DD}"
Local Const $IID_INetFwPolicy2 = "{98325047-C671-4174-8D81-DEFCD3F03186}"
Local Const $TaskList = 'get_CurrentProfileTypes HRESULT(long*);' & _
'get_FirewallEnabled HRESULT(long;short*);'
Local $pNetFwPolicy2 = ObjCreateInterface($CLSID_NetFwPolicy2, $IID_INetFwPolicy2, $TaskList, True)
Local $profileType = 0
Local $Ret = $pNetFwPolicy2.get_CurrentProfileTypes($profileType)
ConsoleWrite('$Ret=' & $Ret & @CRLF)
ConsoleWrite('$profileType=' & $profileType & @CRLF)
Local $enabled = 0
Local $Ret = $pNetFwPolicy2.get_FirewallEnabled($profileType, $enabled)
ConsoleWrite('$Ret=' & $Ret & @CRLF)
ConsoleWrite('$enabled=' & $enabled & @CRLF)