/////////////////////////////////////////////////////////////////////////////
-// Name: msw/utils.cpp
+// Name: src/msw/utils.cpp
// Purpose: Various utilities
// Author: Julian Smart
// Modified by:
#include "wx/log.h"
#endif //WX_PRECOMP
+#include "wx/msw/registry.h"
#include "wx/apptrait.h"
#include "wx/dynlib.h"
#include "wx/dynload.h"
// ----------------------------------------------------------------------------
// 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
// 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);
}
// 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;
+ wxLogNull noLog;
+ wxRegKey key(wxRegKey::HKCU, wxT("ControlPanel\\Owner"));
+ if(!key.Open(wxRegKey::Read))
+ return false;
+ wxString name;
+ if(!key.QueryValue(wxT("Owner"),name))
+ return false;
+ wxStrncpy(buf, name.c_str(), maxSize-1);
+ buf[maxSize-1] = _T('\0');
+ return true;
#elif defined(USE_NET_API)
CHAR szUserName[256];
if ( !wxGetUserId(szUserName, WXSIZEOF(szUserName)) )
}
bool wxGetDiskSpace(const wxString& WXUNUSED_IN_WINCE(path),
- wxLongLong *WXUNUSED_IN_WINCE(pTotal),
- wxLongLong *WXUNUSED_IN_WINCE(pFree))
+ wxDiskspaceSize_t *WXUNUSED_IN_WINCE(pTotal),
+ wxDiskspaceSize_t *WXUNUSED_IN_WINCE(pFree))
{
#ifdef __WXWINCE__
// TODO-CE
#endif
if ( pTotal )
{
- *pTotal = wxLongLong(UL(bytesTotal).HighPart, UL(bytesTotal).LowPart);
+#if wxUSE_LONGLONG
+ *pTotal = wxDiskspaceSize_t(UL(bytesTotal).HighPart, UL(bytesTotal).LowPart);
+#else
+ *pTotal = wxDiskspaceSize_t(UL(bytesTotal).LowPart);
+#endif
}
if ( pFree )
{
+#if wxUSE_LONGLONG
*pFree = wxLongLong(UL(bytesFree).HighPart, UL(bytesFree).LowPart);
+#else
+ *pFree = wxDiskspaceSize_t(UL(bytesFree).LowPart);
+#endif
}
}
else
return false;
}
- wxLongLong lBytesPerCluster = lSectorsPerCluster;
+ wxDiskspaceSize_t lBytesPerCluster = (wxDiskspaceSize_t) lSectorsPerCluster;
lBytesPerCluster *= lBytesPerSector;
if ( pTotal )
return hwnd;
}
-