+#ifdef __WXMSW__
+static bool wxIsDriveAvailable(const wxString dirName)
+{
+#ifdef __WIN32__
+ UINT errorMode = SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOOPENFILEERRORBOX);
+#endif
+ bool success = TRUE;
+
+ // Check if this is a root directory and if so,
+ // whether the drive is avaiable.
+ if (dirName.Len() == 3 && dirName[1] == wxT(':'))
+ {
+ wxString dirNameLower(dirName.Lower());
+ int currentDrive = _getdrive();
+ int thisDrive = (int) (dirNameLower[0] - 'a' + 1) ;
+ int err = _chdrive( thisDrive ) ;
+ _chdrive( currentDrive );
+
+ if (err == -1)
+ {
+ success = FALSE;
+ }
+ }
+#ifdef __WIN32__
+ (void) SetErrorMode(errorMode);
+#endif
+
+ return success;
+}
+#endif
+