]> git.saurik.com Git - wxWidgets.git/commitdiff
Implement wxGetHostName() for Windows CE.
authorVadim Zeitlin <vadim@wxwidgets.org>
Thu, 23 Jul 2009 17:31:06 +0000 (17:31 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Thu, 23 Jul 2009 17:31:06 +0000 (17:31 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@61507 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/msw/utils.cpp

index 7779e616da28a2f1f06e872ffe3ba126f85bcd0e..8ad2280a50d404fb0be14af3b7c1bb417d9fd510 100644 (file)
@@ -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)