About your second question (why ShowWindow(GetConsoleWindow(), SW_HIDE) doesn't work), please see this question: How to hide console in windows 11
ShowWindow(GetConsoleWindow(), SW_HIDE)