I am using inno setup to make an installation file. It required to pull local ip address (which I able to do by querying Win32_NetworkAdapterConfiguration) and check if a specific port is open for the software to run on (which I am currently looking for an answer).
I realize that WMI Win32 classes contain so many useful information. So I wonder which Win32 class should I use to check on this port given that if it is possible to do that?
Thank you,
AFAIK the only WMI class to check if a given port is open is the
NetDiagnostics
WMI class and theConnectToPort
method, but this class only is present in Windows XP. So if you want an option which works in another Windows versions you can try to import (or write your own application and invoke from inno) something like the Winsockconnect
function, like is show on this questionHow to check if a TCP port is available with Delphi?
Just try to bind a socket to it. If it succeeds, it's available.