From 6e788c37df2d5209d66bcf7e3d19bd08cd583667 Mon Sep 17 00:00:00 2001 From: Alexander Kuznetsov Date: Sat, 30 Jul 2011 19:09:34 +0000 Subject: Hides console on win32 even if python path is 2 or more lines Adding tlhelp32.h header --- intern/ghost/intern/GHOST_SystemWin32.cpp | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) (limited to 'intern') diff --git a/intern/ghost/intern/GHOST_SystemWin32.cpp b/intern/ghost/intern/GHOST_SystemWin32.cpp index 4f0e7d8e604..95b3456ce3b 100644 --- a/intern/ghost/intern/GHOST_SystemWin32.cpp +++ b/intern/ghost/intern/GHOST_SystemWin32.cpp @@ -55,6 +55,7 @@ #define _WIN32_IE 0x0501 #include #include +#include // win64 doesn't define GWL_USERDATA #ifdef WIN32 @@ -1242,8 +1243,32 @@ int GHOST_SystemWin32::toggleConsole(int action) { case 3: //hide if no console { - CONSOLE_SCREEN_BUFFER_INFO csbi = {{0}}; - if(!GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbi) || csbi.dwCursorPosition.X || csbi.dwCursorPosition.Y>1) + DWORD sp = GetCurrentProcessId(); + HANDLE ptree = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0); + PROCESSENTRY32 e = {0}; e.dwSize = sizeof(PROCESSENTRY32); + + if( Process32First(ptree, &e)) { + do { //Searches for Blender's PROCESSENTRY32 + if (e.th32ProcessID == sp) { + sp = e.th32ParentProcessID; + Process32First(ptree, &e); + do { //Got parent id, searches for its PROCESSENTRY32 + if (e.th32ProcessID == sp) { + if(strcmp("explorer.exe",e.szExeFile)==0) + { //If explorer, hide cmd + ShowWindow(GetConsoleWindow(),SW_HIDE); + m_consoleStatus = 0; + } + break; + } + + } while( Process32Next(ptree, &e)); + break; + } + } while( Process32Next(ptree, &e)); + } + + CloseHandle(ptree); break; } case 0: //hide -- cgit v1.2.3