WinLua / WinLua-Source-Code

Visual Studio 2017 Project and Installer for WinLua
4 stars 1 forks source link

Distinction between console and graphical programs in Windows #9

Open jcgoble3 opened 6 years ago

jcgoble3 commented 6 years ago

Unlike Unix, Windows and Visual Studio make a distinction between console and graphical executables at compile time. Lua can be used for both, but if you use a lua.exe compiled as a console application to run a graphical program, you will get a console window on the screen that cannot be made to go away until the application exits. There is no runtime option to disable this; it has to be chosen at compile time.

The official Python distributions solve this problem by providing two executables on Windows, python.exe and pythonw.exe. python.exe is compiled as a console application, while pythonw.exe is compiled as a graphical application. Python also supports the .pyw file extension, which is tied to pythonw.exe via Windows file associations.

It would be nice to do the same here. Note that this does require some additional code, since graphical applications call a different "main" function IIRC, and you obviously would not want a REPL. The old Lua for Windows project did this (provided two executables and the extra file extension).

RussellHaley commented 6 years ago

Hi Johnathan, I thought I had commented on this the same day you posted it. I had meant to say thank you and I'll look into it. I have seen applications us the *w.exe before and never understood why. Thanks for the report, as well as clarifying a decades old question.

jcgoble3 commented 6 years ago

Thanks, and glad I could help clarify that for you. There's no rush on my part; I don't have a specific use case myself. But it's general enough that the use case definitely exists for other people, so worth looking into.