From 32cdc45397d8c0a24735f84e1dcf83bba1980f2d Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Thu, 23 Jul 2009 17:31:06 +0000 Subject: [PATCH] Implement wxGetHostName() for Windows CE. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@61507 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/msw/utils.cpp | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/msw/utils.cpp b/src/msw/utils.cpp index 7779e616da..8ad2280a50 100644 --- a/src/msw/utils.cpp +++ b/src/msw/utils.cpp @@ -127,13 +127,19 @@ static const wxChar eUSERNAME[] = wxT("UserName"); // ---------------------------------------------------------------------------- // Get hostname only (without domain name) -bool wxGetHostName(wxChar *WXUNUSED_IN_WINCE(buf), - int WXUNUSED_IN_WINCE(maxSize)) +bool wxGetHostName(wxChar *buf, int maxSize) { #if defined(__WXWINCE__) - // TODO-CE - return false; -#else + // GetComputerName() is not supported but the name seems to be stored in + // this location in the registry, at least for PPC2003 and WM5 + wxString hostName; + wxRegKey regKey(wxRegKey::HKLM, wxT("Ident")); + if ( !regKey.HasValue(wxT("Name")) || + !regKey.QueryValue(wxT("Name"), hostName) ) + return false; + + wxStrlcpy(buf, hostName.wx_str(), maxSize); +#else // !__WXWINCE__ DWORD nSize = maxSize; if ( !::GetComputerName(buf, &nSize) ) { @@ -141,9 +147,9 @@ bool wxGetHostName(wxChar *WXUNUSED_IN_WINCE(buf), return false; } +#endif // __WXWINCE__/!__WXWINCE__ return true; -#endif } // get full hostname (with domain name if possible) -- 2.45.2