Saturday, February 6, 2021

How to force the visual studio to use the wmain instead of main

How to force the visual studio to use the wmain instead of main

  1. /ENTRY (Entry-Point Symbol)
  2. The /ENTRY option specifies an entry point function as the starting address for an .exe file or DLL.

  3. How to force the visual studio to use the wmain instead of main
  4. A Question:I'm in need of parsing unicode parameters, so I wanted to use the wmain instead. So instead of:

    int main(int argc, char** argv)
    I would like to use
    int wmain(int argc, wchar_t** argv)

    The problem is that the visual studio is not recognizing the wmain, and it is trying to use main instead:

    A Solution: You are getting close, not quite close enough. The CRT has four entrypoints:

    • mainCRTStartup => calls main(), the entrypoint for console mode apps
    • wmainCRTStartup => calls wmain(), as above but the Unicode version
    • WinMainCRTStartup => calls WinMain(), the entrypoint for native Windows apps
    • wWinMainCRTStartup => calls wWinMain(), as above but the Unicode version
    So it is /ENTRY:wmainCRTStartup
    Do beware that the command line arguments are converted to Unicode assuming the default console code page. Which is a bit unpredictable, it is the legacy 437 OEM code page only in Western Europe and the Americas. The user might need to use the CHCP command (CHange Code Page) and tinker with the console window font to keep you happy. YMMV.

  5. Hide console of Windows Application
  6. A Question: I have a Qt application, and when I run this application, there is a console opening behind it. In development it is nice because i see debug outputs on the console, but when I want to give this executable to the customer there should be no console window. how do I hide it? (I am using Visual Studio 2008)

    It sounds like your linker configuration is incorrect. Right-click the project, Properties, Linker, System, SubSystem setting. Make sure "Windows" is selected, not "Console". And, change main() to WinMain().

    A Solution:In the project build linker options set

    • /SUBSYSTEM:windows
    • /ENTRY:mainCRTStartup

    A Better Solution: If you use Properties->Linker->System->SubSystem | Windows And get a linker error.

    You can look at Linker->Advanced-> Entry Point
    and set the value to the name of your "main" function. That is your Entry Point becomes, main, if your main function is a "main".

  7. This is a paragraph.

  8. This is a paragraph.

  9. This is a paragraph.

  10. This is a paragraph.

  11. This is a paragraph.

  12. This is a paragraph.

  13. This is a paragraph.

  14. This is a paragraph.

  15. This is a paragraph.

  16. This is a paragraph.

  17. This is a paragraph.

  18. This is a paragraph.

  19. This is a paragraph.

  20. This is a paragraph.

  21. This is a paragraph.

No comments:

Post a Comment