Page 1 of 1

ComputerName() returns ComputerName.Router

Posted: Fri May 17, 2019 7:16 am
by Lebostein
In my case ComputerName() returns "MacBook.local" on work and "MacBook.Speedport_Router_xyz" at home.

Is this a bug or an undocumented feature?

Re: ComputerName() returns ComputerName.Router

Posted: Fri May 17, 2019 10:06 pm
by wombats
I don't know about PureBasic's function, but you can get a better version like this:

Code: Select all

host = CocoaMessage(0, 0, "NSHost currentHost")

hostName = CocoaMessage(0, host, "name")
string = CocoaMessage(0, hostName, "UTF8String")
Debug PeekS(string, -1, #PB_UTF8)

localisedName = CocoaMessage(0, host, "localizedName")
string = CocoaMessage(0, localisedName, "UTF8String")
Debug PeekS(string, -1, #PB_UTF8)

Debug ComputerName()

Re: ComputerName() returns ComputerName.Router

Posted: Sat May 18, 2019 1:05 am
by mk-soft
Thanks

The Purebasic version returns the wrong machine name when virtual machines are running.