Reader small image

You're reading from  C++ Windows Programming

Product typeBook
Published inSep 2016
Reading LevelIntermediate
PublisherPackt
ISBN-139781786464224
Edition1st Edition
Languages
Right arrow
Author (1)
Stefan Björnander
Stefan Björnander
author image
Stefan Björnander

Stefan Björnander is the author of the books Microsoft Windows C++ and C++ Windows Programming. He holds a Master of Engineering and a Licentiate in Computer Science. He has worked as a software developer and as a teacher in computer science and mathematics for many years.
Read more about Stefan Björnander

Right arrow

The WinMain function


In the Win32 API, WinMain is the function equivalent to main. Each application must include the definition of the WinMain function. In order for Small Windows to work, WinMain is implemented as a part of Small Windows, while MainWindow has to be implemented by the user of Small Windows for each project. To sum it up, here are the three kinds of main functions:

Regular C/C++

Win32 API

Small Windows

main

WinMain

MainWindow

The WinMain function is called by the Windows system and takes the following parameters:

  • instanceHandle: This holds the handle of the application

  • prevInstanceHandle: This is present due to backward compatibility but is always null

  • commandLine: This is a null-terminated character (char, not TCHAR) array holding the arguments for the application, separated by spaces

  • commandShow: This holds the preferred appearance of the main window

WinMain.cpp

#include "SmallWindows.h" 
 
int WINAPI WinMain(HINSTANCE instanceHandle, 
            ...
lock icon
The rest of the page is locked
Previous PageNext Page
You have been reading a chapter from
C++ Windows Programming
Published in: Sep 2016Publisher: PacktISBN-13: 9781786464224

Author (1)

author image
Stefan Björnander

Stefan Björnander is the author of the books Microsoft Windows C++ and C++ Windows Programming. He holds a Master of Engineering and a Licentiate in Computer Science. He has worked as a software developer and as a teacher in computer science and mathematics for many years.
Read more about Stefan Björnander