svcore  1.9
Init.cpp
Go to the documentation of this file.
00001 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*-  vi:set ts=8 sts=4 sw=4: */
00002 
00003 /*
00004     Sonic Visualiser
00005     An audio file viewer and annotation editor.
00006     Centre for Digital Music, Queen Mary, University of London.
00007     This file copyright 2006 Chris Cannam.
00008     
00009     This program is free software; you can redistribute it and/or
00010     modify it under the terms of the GNU General Public License as
00011     published by the Free Software Foundation; either version 2 of the
00012     License, or (at your option) any later version.  See the file
00013     COPYING included with this distribution for more information.
00014 */
00015 
00016 #include <iostream>
00017 
00018 #include <qglobal.h>
00019 
00020 #ifdef Q_OS_WIN32
00021 
00022 #include <fcntl.h>
00023 
00024 // required for SetDllDirectory
00025 #define _WIN32_WINNT 0x0502
00026 #include <windows.h>
00027 
00028 // Set default file open mode to binary
00029 //#undef _fmode
00030 //int _fmode = _O_BINARY;
00031 
00032 void redirectStderr()
00033 {
00034 #ifdef NO_PROBABLY_NOT
00035     HANDLE stderrHandle = GetStdHandle(STD_ERROR_HANDLE);
00036     if (!stderrHandle) return;
00037 
00038     AllocConsole();
00039 
00040     CONSOLE_SCREEN_BUFFER_INFO info;
00041     GetConsoleScreenBufferInfo(stderrHandle, &info);
00042     info.dwSize.Y = 1000;
00043     SetConsoleScreenBufferSize(stderrHandle, info.dwSize);
00044 
00045     int h = _open_osfhandle((long)stderrHandle, _O_TEXT);
00046     if (h) {
00047         FILE *fd = _fdopen(h, "w");
00048         if (fd) {
00049             *stderr = *fd;
00050             setvbuf(stderr, NULL, _IONBF, 0);
00051         }
00052     }
00053 #endif
00054 }
00055 
00056 #endif
00057 
00058 extern void svSystemSpecificInitialisation()
00059 {
00060 #ifdef Q_OS_WIN32
00061     redirectStderr();
00062 
00063     // Remove the CWD from the DLL search path, just in case
00064     SetDllDirectory(L"");
00065     putenv("PATH=");
00066 #else
00067 #endif
00068 }
00069 
00070 
00071