Winmain: Remove Windows CE.

Remove #ifdef sections for Q_OS_WINCE and wince .pro file clauses in library.

Task-number: QTBUG-51673
Change-Id: I473f215066db819a273f293940dcce9fe03152c3
Reviewed-by: Joerg Bornemann <joerg.bornemann@theqtcompany.com>
This commit is contained in:
Friedemann Kleint 2016-03-09 14:29:01 +01:00
parent 8042c5243c
commit 390598cb43
2 changed files with 2 additions and 61 deletions

View File

@ -43,9 +43,7 @@
#include "qstring.h"
#include "qvector.h"
#ifndef Q_OS_WINCE
# include <shlobj.h>
#endif
#include <shlobj.h>
/*
This file contains the code in the qtmain library for Windows.
@ -59,11 +57,7 @@
QT_BEGIN_NAMESPACE
#if defined(Q_OS_WINCE)
extern void __cdecl qWinMain(HINSTANCE, HINSTANCE, LPSTR, int, int &, QVector<char *> &);
#else
extern void qWinMain(HINSTANCE, HINSTANCE, LPSTR, int, int &, QVector<char *> &);
#endif
QT_END_NAMESPACE
@ -74,12 +68,8 @@ QT_USE_NAMESPACE
int qMain(int, char **);
#define main qMain
#else
#ifdef Q_OS_WINCE
extern "C" int __cdecl main(int, char **);
#else
extern "C" int main(int, char **);
#endif
#endif
/*
WinMain() - Initializes Windows and calls user's startup function main().
@ -87,8 +77,6 @@ extern "C" int main(int, char **);
application.
*/
#ifndef Q_OS_WINCE
// Convert a wchar_t to char string, equivalent to QString::toLocal8Bit()
// when passed CP_ACP.
static inline char *wideToMulti(int codePage, const wchar_t *aw)
@ -116,48 +104,3 @@ extern "C" int APIENTRY WinMain(HINSTANCE, HINSTANCE, LPSTR /*cmdParamarg*/, int
delete [] argv;
return exitCode;
}
#else // !Q_OS_WINCE
int WINAPI WinMain(HINSTANCE instance, HINSTANCE prevInstance, LPWSTR /*wCmdParam*/, int cmdShow)
{
QByteArray cmdParam = QString::fromWCharArray(GetCommandLine()).toLocal8Bit();
wchar_t appName[MAX_PATH];
GetModuleFileName(0, appName, MAX_PATH);
cmdParam.prepend(QString(QLatin1String("\"%1\" ")).arg(QString::fromWCharArray(appName)).toLocal8Bit());
int argc = 0;
QVector<char *> argv(8);
qWinMain(instance, prevInstance, cmdParam.data(), cmdShow, argc, argv);
wchar_t uniqueAppID[MAX_PATH];
GetModuleFileName(0, uniqueAppID, MAX_PATH);
QString uid = QString::fromWCharArray(uniqueAppID).toLower().replace(QLatin1String("\\"), QLatin1String("_"));
// If there exists an other instance of this application
// it will be the owner of a mutex with the unique ID.
HANDLE mutex = CreateMutex(NULL, TRUE, (LPCWSTR)uid.utf16());
if (mutex && ERROR_ALREADY_EXISTS == GetLastError()) {
CloseHandle(mutex);
// The app is already running, so we use the unique
// ID to create a unique messageNo, which is used
// as the registered class name for the windows
// created. Set the first instance's window to the
// foreground, else just terminate.
// Use bitwise 0x01 OR to reactivate window state if
// it was hidden
UINT msgNo = RegisterWindowMessage((LPCWSTR)uid.utf16());
HWND aHwnd = FindWindow((LPCWSTR)QString::number(msgNo).utf16(), 0);
if (aHwnd)
SetForegroundWindow((HWND)(((ULONG)aHwnd) | 0x01));
return 0;
}
int result = main(argc, argv.data());
CloseHandle(mutex);
return result;
}
#endif // Q_OS_WINCE

View File

@ -21,7 +21,7 @@ winrt {
} else {
SOURCES = qtmain_win.cpp
!wince: LIBS += -lshell32
LIBS += -lshell32
}
load(qt_installs)
@ -31,5 +31,3 @@ TARGET = $$qtLibraryTarget($$TARGET$$QT_LIBINFIX) #do this towards the end
load(qt_targets)
load(qt_build_paths)
load(qt_common)
wince: QMAKE_POST_LINK =