Paul, your solution is great. The IP address to string function began to fail for me on upgrade from Windows 7 to Windows 10 (would only return IP address and not computer name), aside from becoming very slow as well.
On Windows machines, you can also ask kernel32 for GetComputerNameA