Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 140231
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T07:34:39+00:00 2026-05-11T07:34:39+00:00

Windows GUI applications written in C/C++ have ‘WinMain’ as an entry point (rather than

  • 0

Windows GUI applications written in C/C++ have ‘WinMain’ as an entry point (rather than ‘main’). My understanding of this is that the compiler generates a ‘main’ function to be called by the C Runtime. This ‘main’ function sets up the necessary environment for the GUI and calls into ‘WinMain’ (specifying the instance handles etc.).

In short, I believe console and GUI application startup to differ in the following way:

Console application: C Runtime –> ‘main’ function (hand-coded)

GUI application: C Runtime –> ‘main’ function (compiler-generated) –> ‘WinMain’ function (hand-coded)

I would like to both validate this understanding and find out how I can hand-code a Windows GUI with just a ‘main’ function (i.e. without having to write ‘WinMain’).

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T07:34:40+00:00Added an answer on May 11, 2026 at 7:34 am

    You have an incorrect understanding. The difference between main and WinMain, apart from some differet initialization code, is the parameters passed to it.

    main looks like this:

    int main(int argc, char* argv[]); 

    While WinMain looks like this:

    int WINAPI WinMain(HINSTANCE hInstance,     HINSTANCE hPrevInstance,     LPSTR lpCmdLine,     int nCmdShow ); 

    Something has to setup those parameters and make the call, and that’s the startup code. When you compile and link a program, one of the linker parameters is the entry point, and that will be, depending on a console or GUI app, a different bit of startup code.

    You can certainly write your own startup code, just go into your visual c++ source directory and you can find the startup code, it’s called crt0.c and it’s in the VC\crt\src directory.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a C++ Win32 application that was written as a Windows GUI project,
I have this application (Windows form application written in Visual C++) from a colleague
I have a rather simple multi-threaded VCL gui application written with Delphi 2007. I
We have a mature Windows desktop application written in C++. The application's GUI sits
I'm not entirely sure this is possible. I have a legacy GUI application written
Suppose I have a GUI-only application that runs on Windows and I'd like to
Imagine you are on Windows 7 and you have to write a GUI for
I have written an image processing application with the GUI part written in Java
I have a very large, complex (million+ LOC) Windows application written in C++. We
I have a GUI application written in C/C++ using gcc. I need some recommendations

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.