void WINAPI entrypoint (void)

so let assume one does not need all the parameters provided by WinMain,
how can one have the entry point to be

win WINAPI entrypoint(void) ...???
closed account (E0p9LyTq)
The Win API has the WinMain function defined a certain way, with four parameters, no more no less.

If you don't want to use a particular parameter then use the UNREFERENCED_PARAMETER macro on the parameter. With Win32 apps the "HINSTANCE hPrevInstance" parameter is always ignored, it is an artifact of Win16.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#define UNICODE
#define _UNICODE

#include <windows.h>

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR szCmdLine, int iCmdShow)
{
   UNREFERENCED_PARAMETER(hInstance)
   UNREFERENCED_PARAMETER(hPrevInstance)
   UNREFERENCED_PARAMETER(szCmdLine)
   UNREFERENCED_PARAMETER(iCmdShow)

   MessageBoxW(NULL, L"Hello, Windows 10!", L"HelloMsg", MB_OK);

   return 0;
}

If you are compiling your source as a .cpp file you can use
int WINAPI WinMain(HINSTANCE /*hInstance*/, HINSTANCE /*hPrevInstance*/, LPSTR /*szCmdLine*/, int /*iCmdShow*/)
or
int WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int)

You can create a Windows app with using the WinMain parameters:
1
2
3
4
5
6
7
8
#include <windows.h>

int main()
{
   MessageBoxW(NULL, L"Hello, Windows 10!", L"HelloMsg", MB_OK);

   return 0;
}
thanks FurryGuy

You can create a Windows app with using the WinMain parameters:

you meant "You can create a Windows app "without" using the WinMain parameters?

so if I understood well..in the last code box,
you're saying that by including <windows.h>
I can have a custom entry point???
You can have a custom entry point, but then you need to not use any C library functions at all. It's not worth the trouble unless you want a very compact executable.
Topic archived. No new replies allowed.