haijie1223 Posted yesterday at 02:40 PM Posted yesterday 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 yesterday at 05:50 PM Solution Posted yesterday at 05:50 PM (edited) It is because INetFwPolicy2 inherits from IDispatch. You need to add the methods of IDispatch before. Edited yesterday 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 23 hours ago Posted 23 hours ago (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 22 hours ago by jugador
haijie1223 Posted 16 hours ago Author Posted 16 hours ago (edited) 7 hours ago, Nine said: It is because INetFwPolicy2 inherits from IDispatch. You need to add the methods of IDispatch before. thanks Edited 16 hours ago by haijie1223
haijie1223 Posted 16 hours ago Author Posted 16 hours ago (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 16 hours ago 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