]> git.saurik.com Git - wxWidgets.git/blobdiff - src/msw/utils.cpp
Don't use Windows handles directly in headers
[wxWidgets.git] / src / msw / utils.cpp
index 672db642201a284bd99377560f93a78e7150e9ff..45f268a5107e2ecba6d7ca17465326b2a8499100 100644 (file)
@@ -31,6 +31,7 @@
     #include "wx/log.h"
 #endif  //WX_PRECOMP
 
+#include "wx/msw/registry.h"
 #include "wx/apptrait.h"
 #include "wx/dynlib.h"
 #include "wx/dynload.h"
@@ -288,13 +289,15 @@ bool wxGetUserName(wxChar *buf, int maxSize)
     wxCHECK_MSG( buf && ( maxSize > 0 ), false,
                     _T("empty buffer in wxGetUserName") );
 #if defined(__WXWINCE__)
-    wxRegKey key(wxRegKey::HKCU, wxT("Control Panel\\Owner\\Owner"));
+    wxLogNull noLog;
+    wxRegKey key(wxRegKey::HKCU, wxT("ControlPanel\\Owner"));
     if(!key.Open(wxRegKey::Read))
         return false;
     wxString name;
-    if(!key.QueryValue(wxEmptyString, name))
+    if(!key.QueryValue(wxT("Owner"),name))
         return false;
-    wxStrncpy(buf, name.c_str(), maxSize);
+    wxStrncpy(buf, name.c_str(), maxSize-1);
+    buf[maxSize-1] = _T('\0');
     return true;
 #elif defined(USE_NET_API)
     CHAR szUserName[256];