haijie1223 Posted Tuesday at 02:40 PM Posted Tuesday at 02:40 PM 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)
Solution Nine Posted Tuesday at 05:50 PM Solution Posted Tuesday at 05:50 PM (edited) It is because INetFwPolicy2 inherits from IDispatch. You need to add the methods of IDispatch before. Edited Tuesday at 05:52 PM by Nine typo “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Debug Messages Monitor UDF Screen Scraping Round Corner GUI UDF Multi-Threading Made Easy Interface Object based on Tag
jugador Posted Tuesday at 06:45 PM Posted Tuesday at 06:45 PM (edited) No tested Local Const $CLSID_NetFwPolicy2 = "{E2B3C97F-6AE1-41AC-817A-F6F92166D7DD}" Local Const $IID_INetFwPolicy2 = "{98325047-C671-4174-8D81-DEFCD3F03186}" Local $pNetFwPolicy2 = ObjCreateInterface($CLSID_NetFwPolicy2, $IID_INetFwPolicy2, Default) ConsoleWrite($pNetFwPolicy2.CurrentProfileTypes & @CRLF) $pNetFwPolicy2 = 0 if not then you have add IDispatch and INetFwPolicy2 all the methods. Edited Tuesday at 07:04 PM by jugador
haijie1223 Posted yesterday at 01:11 AM Author Posted yesterday at 01:11 AM (edited) 7 hours ago, Nine said: It is because INetFwPolicy2 inherits from IDispatch. You need to add the methods of IDispatch before. thanks Edited yesterday at 01:19 AM by haijie1223
haijie1223 Posted yesterday at 01:12 AM Author Posted yesterday at 01:12 AM (edited) 6 hours ago, jugador said: No tested Local Const $CLSID_NetFwPolicy2 = "{E2B3C97F-6AE1-41AC-817A-F6F92166D7DD}" Local Const $IID_INetFwPolicy2 = "{98325047-C671-4174-8D81-DEFCD3F03186}" Local $pNetFwPolicy2 = ObjCreateInterface($CLSID_NetFwPolicy2, $IID_INetFwPolicy2, Default) ConsoleWrite($pNetFwPolicy2.CurrentProfileTypes & @CRLF) $pNetFwPolicy2 = 0 if not then you have add IDispatch and INetFwPolicy2 all the methods. This code also works fine, thank you, I didn't check the help file carefully. Edited yesterday at 01:19 AM by haijie1223
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now