+#if defined(__WIN32__) && !defined(__TWIN32__) && ! (defined(__GNUWIN32__) && !defined(__MINGW32__))
+ // TODO should use GetComputerNameEx() when available
+ WSADATA wsa;
+ if ( WSAStartup(MAKEWORD(1, 1), &wsa) == 0 )
+ {
+ wxString host;
+ char bufA[256];
+ if ( gethostname(bufA, WXSIZEOF(bufA)) == 0 )
+ {
+ // gethostname() won't usually include the DNS domain name, for
+ // this we need to work a bit more
+ if ( !strchr(bufA, '.') )
+ {
+ struct hostent *pHostEnt = gethostbyname(bufA);
+
+ if ( pHostEnt )
+ {
+ // Windows will use DNS internally now
+ pHostEnt = gethostbyaddr(pHostEnt->h_addr, 4, PF_INET);
+ }
+
+ if ( pHostEnt )
+ {
+ host = pHostEnt->h_name;
+ }
+ }
+ }
+
+ WSACleanup();
+
+ if ( !!host )
+ {
+ wxStrncpy(buf, host, maxSize);
+
+ return TRUE;
+ }
+ }
+#endif // Win32
+