-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwinmain.h
34 lines (33 loc) · 1.06 KB
/
winmain.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
// Small alternative startfile for WinMain()
// Build with gcc perms:
// -nostartfiles -mwindows -lshlwapi
#pragma once
#ifndef STARTFILE_WINMAIN_H
#define STARTFILE_WINMAIN_H
#include <windows.h>
#include <shlwapi.h>
#ifdef UNICODE
int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
PWSTR lpCmdLine, int nCmdShow);
#else
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR lpCmdLine, int nCmdShow);
#endif
int __cdecl WinMainCRTStartup() {
STARTUPINFO startupInfo;
ZeroMemory(&startupInfo, sizeof(STARTUPINFO));
GetStartupInfo(&startupInfo);
DWORD __nShowCmd = SW_SHOWDEFAULT;
__nShowCmd = startupInfo.dwFlags & STARTF_USESHOWWINDOW
? startupInfo.wShowWindow
: SW_SHOWDEFAULT;
const int exitCode =
#ifdef UNICODE
wWinMain(GetModuleHandleW(NULL), NULL, PathGetArgsW(GetCommandLineW()), __nShowCmd);
#else
WinMain(GetModuleHandleA(NULL), NULL, PathGetArgsA(GetCommandLineA()), __nShowCmd);
#endif
ExitProcess(exitCode);
return exitCode;
}
#endif