Creating Objects in VBA and VBS

Recently, in an attempt to access the properties and methods of the Windows firewall in I referenced hnetcfg.dll and could change the dimension for objects such as inetfwMGr , inetfwPolicy , etc.

But I could not create objects for them as needed, for example,
set obj = new inetfwmgr
does not work

Reading around, I found out that I need to use CreateObject("hnetcfg.FwMgr")
move on.

I want to know how you can find out which objects can be created from a given DLL in VBA. looking at the link here . I cannot find a single key indicating that you need to create an hnetcfg.FwMgr object to continue. Why FwMgr ? How to find out if other objects created from hnetgfg.dll ? Is this information as a link a link I did not see or implicit if someone is looking at the hnetcfg properties?

Any insight would be appreciated. thanks

+4
source share
2 answers

I don’t know anything about this DLL, but I think it will help.

You can use CreateObject, and in the long run you may need to increase portability. This is called late binding. On the other hand, if you set a link to the dll, you can measure and create new NetFwLibLib objects ("early binding"). The advantage here is that you get intellisense and you can check its properties in the object browser. Here is the code written in Excel VBE:

 Sub test() Dim test As NetFwTypeLib.INetFwMgr Set test = New NetFwTypeLib.INetFwMgr With test .CurrentProfileType = ... End With End Sub 

Alternatively, you can use the Object Browser to validate FwTypeLib. Just hit F2 (in Excel VBE in this case) and you will see something like this:

enter image description here

+5
source

You need to use a type library viewer. I highly recommend TLViewer .

iTripoli also has a decent.

There are also many scripting links for the Windows Firewall.

Windows Firewall Scripting and Settings Reference

Windows Firewall Script (ActiveXperts)

+2
source

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


All Articles