mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2025-03-01 10:33:28 +00:00
feat: Windows console window (#860)
* Add console option for windows * add changelog entry * chnagelog * update changelog * Daran solls nicht fehlen * nsis: Install vcredist * Disable vc_redist detection
This commit is contained in:
@@ -9,6 +9,7 @@ endif()
|
||||
find_package(Qt5Widgets REQUIRED)
|
||||
|
||||
add_executable(hyperiond
|
||||
console.h
|
||||
hyperiond.h
|
||||
systray.h
|
||||
hyperiond.cpp
|
||||
|
34
src/hyperiond/console.h
Normal file
34
src/hyperiond/console.h
Normal file
@@ -0,0 +1,34 @@
|
||||
#include <Windows.h>
|
||||
|
||||
// https://stackoverflow.com/a/57241985
|
||||
void CreateConsole()
|
||||
{
|
||||
if (!AllocConsole()) {
|
||||
// Add some error handling here.
|
||||
// You can call GetLastError() to get more info about the error.
|
||||
return;
|
||||
}
|
||||
|
||||
// std::cout, std::clog, std::cerr, std::cin
|
||||
FILE* fDummy;
|
||||
freopen_s(&fDummy, "CONOUT$", "w", stdout);
|
||||
freopen_s(&fDummy, "CONOUT$", "w", stderr);
|
||||
freopen_s(&fDummy, "CONIN$", "r", stdin);
|
||||
//std::cout.clear();
|
||||
//std::clog.clear();
|
||||
//std::cerr.clear();
|
||||
//std::cin.clear();
|
||||
|
||||
|
||||
/*// std::wcout, std::wclog, std::wcerr, std::wcin
|
||||
HANDLE hConOut = CreateFile(_T("CONOUT$"), GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
|
||||
HANDLE hConIn = CreateFile(_T("CONIN$"), GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
|
||||
SetStdHandle(STD_OUTPUT_HANDLE, hConOut);
|
||||
SetStdHandle(STD_ERROR_HANDLE, hConOut);
|
||||
SetStdHandle(STD_INPUT_HANDLE, hConIn);
|
||||
std::wcout.clear();
|
||||
std::wclog.clear();
|
||||
std::wcerr.clear();
|
||||
std::wcin.clear();
|
||||
*/
|
||||
}
|
@@ -9,8 +9,8 @@
|
||||
#endif
|
||||
// getpid()
|
||||
#ifdef _WIN32
|
||||
#include "console.h"
|
||||
#include <process.h>
|
||||
//#include <Windows.h>
|
||||
#else
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
@@ -143,10 +143,6 @@ int main(int argc, char** argv)
|
||||
{
|
||||
#ifndef _WIN32
|
||||
setenv("AVAHI_COMPAT_NOWARN", "1", 1);
|
||||
#endif
|
||||
#ifdef _WIN32
|
||||
// We can get a console window also in app gui mode conditional
|
||||
//AllocConsole();
|
||||
#endif
|
||||
// initialize main logger and set global log level
|
||||
Logger *log = Logger::getInstance("MAIN");
|
||||
@@ -195,12 +191,22 @@ int main(int argc, char** argv)
|
||||
BooleanOption & silentOption = parser.add<BooleanOption> ('s', "silent", "do not print any outputs");
|
||||
BooleanOption & verboseOption = parser.add<BooleanOption> ('v', "verbose", "Increase verbosity");
|
||||
BooleanOption & debugOption = parser.add<BooleanOption> ('d', "debug", "Show debug messages");
|
||||
parser.add<BooleanOption> (0x0, "desktop", "show systray on desktop");
|
||||
parser.add<BooleanOption> (0x0, "service", "force hyperion to start as console service");
|
||||
#ifdef WIN32
|
||||
BooleanOption & consoleOption = parser.add<BooleanOption> ('c', "console", "Open a console window to view log output");
|
||||
#endif
|
||||
parser.add<BooleanOption> (0x0, "desktop", "show systray on desktop");
|
||||
parser.add<BooleanOption> (0x0, "service", "force hyperion to start as console service");
|
||||
Option & exportEfxOption = parser.add<Option> (0x0, "export-effects", "export effects to given path");
|
||||
|
||||
parser.process(*qApp);
|
||||
|
||||
#ifdef WIN32
|
||||
if (parser.isSet(consoleOption))
|
||||
{
|
||||
CreateConsole();
|
||||
}
|
||||
#endif
|
||||
|
||||
int logLevelCheck = 0;
|
||||
if (parser.isSet(silentOption))
|
||||
{
|
||||
|
Reference in New Issue
Block a user