wxGetUserName for WinCE.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@36221 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Włodzimierz Skiba 2005-11-22 09:20:41 +00:00
parent 5ff751d600
commit 119f7bb745

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////////
// Name: msw/utils.cpp
// Name: src/msw/utils.cpp
// Purpose: Various utilities
// Author: Julian Smart
// Modified by:
@ -110,8 +110,13 @@
// ----------------------------------------------------------------------------
// In the WIN.INI file
#if (!defined(USE_NET_API) && !defined(__WXWINCE__)) || defined(__WXMICROWIN__)
static const wxChar WX_SECTION[] = wxT("wxWindows");
#endif
#if (!defined(USE_NET_API) && !defined(__WXWINCE__))
static const wxChar eUSERNAME[] = wxT("UserName");
#endif
// ============================================================================
// implementation
@ -262,8 +267,8 @@ bool wxGetUserId(wxChar *WXUNUSED_IN_WINCE(buf),
// Can't assume we have NIS (PC-NFS) or some other ID daemon
// So we ...
if ( (user = wxGetenv(wxT("USER"))) == NULL &&
(user = wxGetenv(wxT("LOGNAME"))) == NULL )
if ( (user = wxGetenv(wxT("USER"))) == NULL &&
(user = wxGetenv(wxT("LOGNAME"))) == NULL )
{
// Use wxWidgets configuration data (comming soon)
GetProfileString(WX_SECTION, eUSERID, default_id, buf, maxSize - 1);
@ -278,12 +283,19 @@ bool wxGetUserId(wxChar *WXUNUSED_IN_WINCE(buf),
}
// Get user name e.g. Julian Smart
bool wxGetUserName(wxChar *WXUNUSED_IN_WINCE(buf),
int WXUNUSED_IN_WINCE(maxSize))
bool wxGetUserName(wxChar *buf, int maxSize)
{
wxCHECK_MSG( buf && ( maxSize > 0 ), false,
_T("empty buffer in wxGetUserName") );
#if defined(__WXWINCE__)
// TODO-CE
return false;
wxRegKey key(wxRegKey::HKCU, wxT("Control Panel\\Owner\\Owner"));
if(!key.Open(wxRegKey::Read))
return false;
wxString name;
if(!key.QueryValue(wxEmptyString, name))
return false;
wxStrncpy(buf, name.c_str(), maxSize);
return true;
#elif defined(USE_NET_API)
CHAR szUserName[256];
if ( !wxGetUserId(szUserName, WXSIZEOF(szUserName)) )
@ -1544,4 +1556,3 @@ wxCreateHiddenWindow(LPCTSTR *pclassname, LPCTSTR classname, WNDPROC wndproc)
return hwnd;
}