#endif
# if defined(__WXDEBUG__) && wxUSE_GLOBAL_MEMORY_OPERATORS && wxUSE_DEBUG_NEW_ALWAYS
-# define new new(__FILE__,__LINE__)
+# define new new(__TFILE__,__LINE__)
# endif
#endif
DWORD nSize = maxSize;
if ( !::GetComputerName(buf, &nSize) )
{
- wxLogLastError("GetComputerName");
+ wxLogLastError(wxT("GetComputerName"));
return FALSE;
}
bool wxDirExists(const wxString& dir)
{
#if defined(__WIN32__)
- WIN32_FIND_DATA fileInfo;
+ DWORD attribs = GetFileAttributes(dir);
+ return ((attribs != (DWORD)-1) && (attribs & FILE_ATTRIBUTE_DIRECTORY));
#else // Win16
#ifdef __BORLANDC__
struct ffblk fileInfo;
#else
struct find_t fileInfo;
#endif
-#endif // Win32/16
-
-#if defined(__WIN32__)
- HANDLE h = ::FindFirstFile(dir, &fileInfo);
-
- if ( h == INVALID_HANDLE_VALUE )
- {
- wxLogLastError("FindFirstFile");
-
- return FALSE;
- }
-
- ::FindClose(h);
-
- return (fileInfo.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0;
-#else // Win16
// In Borland findfirst has a different argument
// ordering from _dos_findfirst. But _dos_findfirst
// _should_ be ok in both MS and Borland... why not?
#endif // Win32/16
}
+// ----------------------------------------------------------------------------
+// env vars
+// ----------------------------------------------------------------------------
+
+bool wxGetEnv(const wxString& var, wxString *value)
+{
+ // first get the size of the buffer
+ DWORD dwRet = ::GetEnvironmentVariable(var, NULL, 0);
+ if ( !dwRet )
+ {
+ // this means that there is no such variable
+ return FALSE;
+ }
+
+ if ( value )
+ {
+ (void)::GetEnvironmentVariable(var, value->GetWriteBuf(dwRet), dwRet);
+ value->UngetWriteBuf();
+ }
+
+ return TRUE;
+}
+
+bool wxSetEnv(const wxString& var, const wxChar *value)
+{
+ // some compilers have putenv() or _putenv() or _wputenv() but it's better
+ // to always use Win32 function directly instead of dealing with them
+#if defined(__WIN32__)
+ if ( !::SetEnvironmentVariable(var, value) )
+ {
+ wxLogLastError(_T("SetEnvironmentVariable"));
+
+ return FALSE;
+ }
+
+ return TRUE;
+#else // no way to set env vars
+ return FALSE;
+#endif
+}
+
// ----------------------------------------------------------------------------
// process management
// ----------------------------------------------------------------------------
case VER_PLATFORM_WIN32_WINDOWS:
str.Printf(_("Windows 9%c"),
- info.dwMinorVersion == 0 ? _T('5') : _T('9'));
+ info.dwMinorVersion == 0 ? _T('5') : _T('8'));
if ( !wxIsEmpty(info.szCSDVersion) )
{
str << _T(" (") << info.szCSDVersion << _T(')');
return TRUE;
}
-#endif // wxUSE_GUI
-
// MSW only: get user-defined resource from the .res file.
// Returns NULL or newly-allocated memory, so use delete[] to clean up.
// get display info
// ----------------------------------------------------------------------------
+// See also the wxGetMousePosition in window.cpp
+// Deprecated: use wxPoint wxGetMousePosition() instead
void wxGetMousePosition( int* x, int* y )
{
POINT pt;
// Return TRUE if we have a colour display
bool wxColourDisplay()
{
- ScreenHDC dc;
- int noCols = GetDeviceCaps(dc, NUMCOLORS);
+ // this function is called from wxDC ctor so it is called a *lot* of times
+ // hence we optimize it a bit but doign the check only once
+ //
+ // this should be MT safe as only the GUI thread (holding the GUI mutex)
+ // can call us
+ static int s_isColour = -1;
+
+ if ( s_isColour == -1 )
+ {
+ ScreenHDC dc;
+ int noCols = ::GetDeviceCaps(dc, NUMCOLORS);
+
+ s_isColour = (noCols == -1) || (noCols > 2);
+ }
- return (noCols == -1) || (noCols > 2);
+ return s_isColour != 0;
}
// Returns depth of screen
if ( height ) *height = GetDeviceCaps(dc, VERTRES);
}
+void wxDisplaySizeMM(int *width, int *height)
+{
+ ScreenHDC dc;
+
+ if ( width ) *width = GetDeviceCaps(dc, HORZSIZE);
+ if ( height ) *height = GetDeviceCaps(dc, VERTSIZE);
+}
+
+
// ---------------------------------------------------------------------------
// window information functions
// ---------------------------------------------------------------------------
#endif // Win16/32
}
+#endif // wxUSE_GUI
+
#if 0
//------------------------------------------------------------------------
// wild character routines
return ((*str == '\0') && (*pattern == '\0'));
};
-#endif
+#endif // 0
#if 0