30#include <VersionHelpers.h>
34#if defined( _MSC_VER )
55 __declspec(dllexport)
void NoHotPatch()
65#if defined( _MSC_VER ) && defined( DEBUG )
68 _CrtSetDbgFlag( _CRTDBG_ALLOC_MEM_DF );
75 SetErrorMode( SEM_FAILCRITICALERRORS | SEM_NOOPENFILEERRORBOX );
80 SetDllDirectory( wxT(
"" ) );
83 SetSearchPathMode( BASE_SEARCH_PATH_ENABLE_SAFE_SEARCHMODE | BASE_SEARCH_PATH_PERMANENT );
87 AttachConsole( wxGetEnv( wxS(
"KICAD_ALLOC_CONSOLE" ),
nullptr ) );
91 bool forceLog = wxGetEnv( wxS(
"KICAD_FORCE_CONSOLE_TRACE" ),
nullptr );
95 wxLog::EnableLogging(
true );
97 wxLog::SetLogLevel( wxLOG_Trace );
99 wxLog::SetActiveTarget(
new wxLogStderr );
108 if( ::AttachConsole( ATTACH_PARENT_PROCESS ) || ( aTryAlloc && ::AllocConsole() ) )
110 #if !defined( __MINGW32__ )
113 if( ::GetStdHandle( STD_INPUT_HANDLE ) != INVALID_HANDLE_VALUE )
115 freopen(
"CONIN$",
"r", stdin );
116 setvbuf( stdin, NULL, _IONBF, 0 );
119 if( ::GetStdHandle( STD_OUTPUT_HANDLE ) != INVALID_HANDLE_VALUE )
121 freopen(
"CONOUT$",
"w", stdout );
122 setvbuf( stdout, NULL, _IONBF, 0 );
125 if( ::GetStdHandle( STD_ERROR_HANDLE ) != INVALID_HANDLE_VALUE )
127 freopen(
"CONOUT$",
"w", stderr );
128 setvbuf( stderr, NULL, _IONBF, 0 );
132 std::ios::sync_with_stdio(
true );
150#if defined( PYTHON_VERSION_MAJOR ) && ( ( PYTHON_VERSION_MAJOR == 3 && PYTHON_VERSION_MINOR >= 8 ) \
151 || PYTHON_VERSION_MAJOR > 3 )
157 return !IsWindows8OrGreater();
167 wxString restartCmd = wxS(
"\"" ) + aCommandLine + wxS(
"\"" );
170 if( restartCmd.length() > RESTART_MAX_CMD_LINE - 1 )
177 hr = ::RegisterApplicationRestart( restartCmd.wc_str(), RESTART_NO_PATCH );
179 return SUCCEEDED( hr );
186 return SUCCEEDED( ::UnregisterApplicationRestart() );
199 ShutdownBlockReasonDestroy( aWindow->GetHandle() );
209 ShutdownBlockReasonDestroy( aWindow->GetHandle() );
211 ShutdownBlockReasonCreate( aWindow->GetHandle(), aReason.wc_str() );
219 PeekMessage( &msg,
nullptr, WM_TIMER, WM_TIMER, PM_NOREMOVE );
225 SetDllDirectory( aPath.c_str() );