Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Toggle main menu visibility
Loading...
Searching...
No Matches
qtentrypoint_win.cpp
Go to the documentation of this file.
1
// Copyright (C) 2019 The Qt Company Ltd.
2
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
3
4
#
include
<
stdlib
.
h
>
// __argc, __argv
5
#
include
<
qt_windows
.
h
>
6
#
include
<
shellapi
.
h
>
7
8
/*
9
This file contains the code in the QtEntryPoint library for Windows.
10
QtEntryPoint contains the Windows startup code and is required for
11
linking to the Qt DLL.
12
13
When a Windows application starts, the WinMain function is
14
invoked.
15
*/
16
17
#
if
defined
(
QT_NEEDS_QMAIN
)
18
int
qMain(
int
,
char
**);
19
#
define
main
qMain
20
#
else
21
int
main
(
int
,
char
**);
22
#
endif
23
24
/*
25
WinMain() - Initializes Windows and calls user's startup function main().
26
NOTE: WinMain() won't be called if the application was linked as a "console"
27
application.
28
*/
29
30
// Convert a wchar_t to char string, equivalent to QString::toLocal8Bit()
31
// when passed CP_ACP.
32
static
inline
char
*
wideToMulti
(
unsigned
int
codePage,
const
wchar_t
*aw)
33
{
34
const
int
required = WideCharToMultiByte(codePage, 0, aw, -1,
nullptr
, 0,
nullptr
,
nullptr
);
35
char
*result =
new
char
[required];
36
WideCharToMultiByte(codePage, 0, aw, -1, result, required,
nullptr
,
nullptr
);
37
return
result;
38
}
39
40
static
inline
int
qtEntryPoint
()
41
{
42
int
argc = __argc;
43
char
**argv = __argv;
44
if
(argv)
45
return
main
(
argc
,
argv
)
;
46
wchar_t
**argvW = CommandLineToArgvW(GetCommandLineW(), &argc);
47
if
(argvW ==
nullptr
)
48
return
-1;
49
argv =
new
char
*[argc + 1];
50
for
(
int
i = 0; i != argc; ++i)
51
argv[i] = wideToMulti(CP_ACP, argvW[i]);
52
argv[argc] =
nullptr
;
53
LocalFree(argvW);
54
const
int
exitCode =
main
(
argc
,
argv
)
;
55
for
(
int
i = 0; (i != argc) && (argv[i] !=
nullptr
); ++i)
56
delete
[] argv[i];
57
delete
[] argv;
58
return
exitCode;
59
}
60
61
extern
"C"
int
WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR,
int
)
62
{
63
return
qtEntryPoint();
64
}
65
66
extern
"C"
int
WINAPI wWinMain(HINSTANCE, HINSTANCE, LPWSTR,
int
)
67
{
68
return
qtEntryPoint();
69
}
qtEntryPoint
static int qtEntryPoint()
Definition
qtentrypoint_win.cpp:40
wideToMulti
static char * wideToMulti(unsigned int codePage, const wchar_t *aw)
Definition
qtentrypoint_win.cpp:32
main
int main(int argc, char *argv[])
[ctor_close]
Definition
src_corelib_animation_qpropertyanimation.cpp:100
qtbase
src
entrypoint
qtentrypoint_win.cpp
Generated on
for Qt by
1.18.0