How to make an invisible window in Delphi console application so that it can only be seen in the processes?

  • one
    why then console? - AseN

3 answers 3

a) A process can destroy a console, which it exclusively owns the FreeConsole function. It is impossible to disconnect from the console and go into the background a la UNIX in Windows NT.

b) A process can find out the window handle of its console screen buffer GetConsoleWindow function and do something with this window, for example, hide it.

    When you create a console application in Delphi 7, for example, you can get rid of the line {$APPTYPE CONSOLE} . As a result of this action, the program will work, but the console will not be displayed.

    • With a certain version of Delphi, this stopped working (in XE8 it definitely does not work). Now you need to go to Project Options → Delphi Compiler → Linking and set the Generate console application parameter to false - diversenok

    Make an ordinary window application, and then hide it by calling application.hide; . Voila! The window will be invisible anyway! Only in the processes it can be set on fire =)

    UPD: If you just need to execute a certain code, then you can use such a wonderful thing as injecting your dll`ki into another address space - Process Injection

    • By the way, how about injecting into someone else's stream? - AseN