Questions tagged [winmain]

WinMain is the user provided entry point for graphical Windows based applications.

WinMain is the user provided entry point for graphical Windows based applications. It is used as an entry point in every such Windows application. WinMain is used to initialize the application, display its main window, and enter a message retrieval-and-dispatch loop that is the top-level control structure for the remainder of the application's execution.

125 questions
115
votes
6 answers

What is a message pump?

In this thread (posted about a year ago) there is a discussion of problems that can come with running Word in a non-interactive session. The (quite strong) advice given there is not to do so. In one post it is stated "The Office APIs all assume…
Matt Gutting
  • 1,151
  • 2
  • 8
  • 3
82
votes
7 answers

WINMAIN and main() in C++ (Extended)

Right, I have looked at this post: Difference between WinMain,main and DllMain in C++ I now know that WINMAIN is used for window applications and main() for consoles. But reading the post doesn't really tell me why exactly what is the difference. I…
Danny
  • 9,199
  • 16
  • 53
  • 75
64
votes
4 answers

What does "WINAPI" in main function mean?

Could you please explain to me the WINAPI word in the WinMain() function? In the simplest way.. #include int -->WINAPI<-- WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { MessageBox(NULL,…
Pyjong
  • 3,095
  • 4
  • 32
  • 50
29
votes
3 answers

Difference between WinMain,main and DllMain in C++

What is the difference between the three functions and when to use them??
Ahmed
  • 7,148
  • 12
  • 57
  • 96
25
votes
5 answers

Undefined reference to WinMain (C++ MinGW)

Currently, I am trying to make a Windows application using C++. For compiling my program I use MinGW (GCC). But as soon as I use int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE, PWSTR pCmdLine, int nCmdShow) instead of int main() the compiler…
wuzipu
  • 253
  • 1
  • 3
  • 4
21
votes
3 answers

"APIENTRY _tWinMain" and "WINAPI WinMain" difference

What are the difference from these 2 function?: int APIENTRY _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow) int WINAPI…
xRobot
  • 25,579
  • 69
  • 184
  • 304
19
votes
4 answers

What is the purpose of __in __out __in_opt __allowed(), how do they work? Should I use similar constructs in my own code?

Some of these Preprocessor definitions are in the WinMain function and other windows library functions. What is their purpose? How do they work? and is it good practice to write them into your implementations or function calls? My initial research…
Lockyer
  • 1,311
  • 1
  • 13
  • 30
17
votes
3 answers

How can I write a Windows application without using WinMain?

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…
Matthew Murdoch
  • 30,874
  • 30
  • 96
  • 127
17
votes
3 answers

What functions does _WinMainCRTStartup perform?

This is part of a series of at least two closely related, but distinct questions. I hope I'm doing the right thing by asking them separately. I'm trying to get my Visual C++ 2008 app to work without the C Runtime Library. It's a Win32 GUI app…
Thomas
  • 174,939
  • 50
  • 355
  • 478
15
votes
7 answers

undefined reference to `WinMain@16' collect2.exe: error: ld returned 1 exit status

I am using eclipse CDT to test the Intel instructions and below is my program: #define cpuid(func,ax,bx,cx,dx)\ __asm__ __volatile__ ("cpuid":\ "=a" (ax), "=b" (bx), "=c" (cx), "=d" (dx) : "a" (func)); int Check_CPU_support_AES() { unsigned int…
annunarcist
  • 1,637
  • 3
  • 20
  • 42
14
votes
2 answers

undefined reference to WinMain@16 C++, SDL-2

I've been getting the error undefined reference to WinMain@16. To save space, here's a link to all the files currently in the project. At present, it shouldn't do much other than create a window, fill it in green and then draw a box in the corner,…
The Orca
  • 220
  • 2
  • 10
12
votes
3 answers

what does WINAPI stand for

I've started to learn Win32 API in C. I saw that the main function is something like int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { .. } but I know that a function in C is like [ReturnType]…
Videron
  • 171
  • 1
  • 3
  • 11
11
votes
2 answers

Why does prevInstance exist in WinMain and wWinMain if it is always NULL

Since I am a beginner, it may be a very basic question. I am starting DirectX 11, and while creating my first application, wWinMain was used, and while searching for difference between WinMain and wWinMain, i came across this parameter…
SpeedBirdNine
  • 4,610
  • 11
  • 49
  • 67
10
votes
1 answer

Undefined reference to WinMain in Cygwin

I am trying to compile and having following problem $ gcc errlib.c -o errlib.o /usr/lib/gcc/x86_64-pc-cygwin/4.8.2/../../../../lib/libcygwin.a(libcmain.o): In function `main': /usr/src/debug/cygwin-1.7.30-1/winsup/cygwin/lib/libcmain.c:39:…
Fawad Nasim
  • 343
  • 2
  • 4
  • 10
10
votes
1 answer

Qt + MinGW + another undefined reference to `WinMain@16' issue

I know, I dug the whole internet to find out what the problem is and nothing has been helpful so far. I am on Windows 7, using: Qt 4.8.3: https://download.qt.io/archive/qt/4.8/4.8.3/qt-win-opensource-4.8.3-mingw.exe MinGW32 4.4.0:…
Massimo Callegari
  • 2,099
  • 1
  • 26
  • 39
1
2 3
8 9