X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/c030b70fc6270c2e44a81f83e69fcc91d2b3c768..2d120f8391920145647ec10e84629bc21fa9f1bb:/src/msw/utils.cpp diff --git a/src/msw/utils.cpp b/src/msw/utils.cpp index fdb322892c..877a9b4aca 100644 --- a/src/msw/utils.cpp +++ b/src/msw/utils.cpp @@ -36,7 +36,9 @@ #ifndef __GNUWIN32__ #include +#ifndef __MWERKS__ #include +#endif #endif //GNUWIN32 #ifdef __GNUWIN32__ @@ -72,7 +74,7 @@ //// BEGIN for console support: VC++ only -#if defined(__WXDEBUG__) && defined(_MSC_VER) && !defined(__NO_VC_CRTDBG__) +#if defined(__WXDEBUG__) && !defined(__WIN16__) && defined(_MSC_VER) && !defined(__NO_VC_CRTDBG__) #define wxUSE_VC_CRTDBG #else #undef wxUSE_VC_CRTDBG @@ -106,7 +108,9 @@ # undef new # endif +#ifndef __WIN16__ # include +#endif # if defined(__WXDEBUG__) && wxUSE_GLOBAL_MEMORY_OPERATORS && wxUSE_DEBUG_NEW_ALWAYS # define new new(__FILE__,__LINE__) @@ -149,7 +153,10 @@ bool wxGetHostName(char *buf, int maxSize) // Get user ID e.g. jacs bool wxGetUserId(char *buf, int maxSize) { -#if defined(__WIN32__) && !defined(__win32s__) && 0 +#if defined(__WIN32__) && !defined(__win32s__) + + // VZ: why should it be so complicated?? +#if 0 // Gets the current user's full name according to the MS article PSS ID // Number: Q119670 // Seems to be the same as the login name for me? @@ -193,11 +200,19 @@ bool wxGetUserId(char *buf, int maxSize) -1, buf, 256, NULL, NULL ); } return( TRUE ); -/* - DWORD nSize = maxSize; - return ::GetUserName(buf, &nSize); -*/ -#else +#else // 1 + DWORD nSize = maxSize; + if ( ::GetUserName(buf, &nSize) == 0 ) + { + wxLogSysError("Can not get user name"); + + return FALSE; + } + + return TRUE; +#endif // 0/1 + +#else // Win16 or Win32s char *user; const char *default_id = "anonymous"; @@ -216,22 +231,7 @@ bool wxGetUserId(char *buf, int maxSize) // Get user name e.g. Julian Smart bool wxGetUserName(char *buf, int maxSize) { - const char *default_name = "Unknown User"; -#if defined(__WIN32__) -/* - DWORD nSize = maxSize; - In VC++ 4.0, results in unresolved symbol __imp__GetUserNameA - if (GetUserName(buf, &nSize)) - return TRUE; - else -*/ - // Could use NIS, MS-Mail or other site specific programs - // Use wxWindows configuration data - GetProfileString(WX_SECTION, eUSERNAME, default_name, buf, maxSize - 1); - return *buf ? TRUE : FALSE; -// } -#else -#if !defined(__WATCOMC__) && !defined(__GNUWIN32__) && wxUSE_PENWINDOWS +#if wxUSE_PENWINDOWS && !defined(__WATCOMC__) && !defined(__GNUWIN32__) extern HANDLE g_hPenWin; // PenWindows Running? if (g_hPenWin) { @@ -245,10 +245,19 @@ bool wxGetUserName(char *buf, int maxSize) { // Could use NIS, MS-Mail or other site specific programs // Use wxWindows configuration data - GetProfileString(WX_SECTION, eUSERNAME, default_name, buf, maxSize - 1); + bool ok = GetProfileString(WX_SECTION, eUSERNAME, "", buf, maxSize - 1) != 0; + if ( !ok ) + { + ok = wxGetUserId(buf, maxSize); + } + + if ( !ok ) + { + strncpy(buf, "Unknown User", maxSize); + } } - return *buf ? TRUE : FALSE; -#endif + + return TRUE; } int wxKill(long pid, int sig) @@ -382,7 +391,7 @@ int wxGetOsVersion(int *majorVsn, int *minorVsn) if (majorVsn) *majorVsn = 0; if (minorVsn) *minorVsn = 0; -#ifdef WIN32 +#if defined(__WIN32__) && !defined(__SC__) OSVERSIONINFO info; memset(&info, 0, sizeof(OSVERSIONINFO)); info.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); @@ -406,7 +415,7 @@ int wxGetOsVersion(int *majorVsn, int *minorVsn) return wxWINDOWS; // error if we get here, return generic value #else // Win16 code... - int retValue ; + int retValue = 0; # ifdef __WINDOWS_386__ retValue = wxWIN386; # else @@ -972,7 +981,9 @@ To download dbwin32, see e.g.: http://ftp.digital.com/pub/micro/NT/WinSite/programr/dbwin32.zip */ +#ifndef __MWERKS__ #include +#endif void OutputDebugStringW95(const char* lpOutputString, ...) { @@ -1049,7 +1060,7 @@ void OutputDebugStringW95(const char* lpOutputString, ...) WaitForSingleObject(heventDBWIN, INFINITE); /* write it to the shared memory */ -#ifdef __BORLANDC__ +#if defined( __BORLANDC__ ) || defined( __MWERKS__ ) *((LPDWORD)lpszSharedMem) = getpid(); #else *((LPDWORD)lpszSharedMem) = _getpid();