mIRC Homepage
Posted By: Jigsy $homeip/$lanip/$localip - 17/08/18 05:56 PM
Some kind of identifier for returning your LAN/WLAN IP would be nice.

At the minute I have to use some PHP code bytecode compiled as an exe to do this.
Posted By: Wims Re: $homeip/$lanip/$localip - 17/08/18 10:02 PM
Code:
alias localip {
  .comopen a wbemScripting.swbemLocator | .comclose a $com(a,connectserver,3,bstr,.,bstr,root\cimv2,dispatch* b)
  .comclose b $com(b,execquery,3,bstr,SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled = True ,dispatch* c)
  var %b $comval(c,0),%r
  while (%b) {
    if ($comval(c,%b,DHCPEnabled)) %r = %r $comval(c,%b,DHCPServer)
    else %r = %r $comval(c,%b,IPAddress)
    dec %b
  }
  .comclose c
  return %r
}
You can try this, I might write something for the external ip later

Not a bad suggestion but it can be done without using 'php byte code'
Posted By: Jigsy Re: $homeip/$lanip/$localip - 18/08/18 12:19 PM
Interesting.

This seems to return 192.168.0.1 instead of my current ip which is 192.168.0.3, though.
Posted By: BhaaL Re: $homeip/$lanip/$localip - 19/08/18 12:22 PM
Not sure, but DHCPServer sounds wrong in the if-part.
Posted By: Wims Re: $homeip/$lanip/$localip - 15/04/20 03:44 AM
Yes, that was not really correct. Before it wasn't possible to handle such result from mIRC's COM implementation, now with the latest beta it's possible:
Code
alias myips {
  .comopen loc WbemScripting.SWbemLocator
  .comclose loc $com(loc, ConnectServer, 3, dispatch* query)
  noop $com(query, ExecQuery, 3, bstr, Select * from Win32_NetworkAdapter WHERE NetConnectionStatus = 2, dispatch* adapter)
  var %a $comval(adapter,0)
  while (%a) {
    hadd -m getips $comval(adapter,%a,Index) $comval(adapter,%a,NetConnectionID)
    dec %a 
  }
  noop $com(query, ExecQuery, 3, bstr, Select * from Win32_NetworkAdapterConfiguration WHERE IPEnabled = True, dispatch* ips)
  var %cv $comval(ips,0)
  while (%cv) {
    if ($hget(getips,$comval(ips, %cv, Index)) != $null) {
      noop $comval(ips, %cv, IPAddress,&test).result
      breplace &test 0 32
      echo -s $bvar(&test,1-).text
    }
    dec %cv
 
  }
  :error
  if ($error || %err) {
    echo -a /myips: $v1
    reseterror
  }
  hfree getips
  .comclose query
  .comclose adapter
  .comclose ips
}
This finds the network adapter which are connected (status = 2) and then find the ip addresses belonging to them.

Note that when the value returned is an array like this, $comval(name,N,IPAddress) would return $null, but it now returns the first element in the array (while you can access the full array using a binvar and splitting on byte 0)
© mIRC Discussion Forums