*/
DWORD lamexp_get_os_version(void)
{
- OSVERSIONINFO osVerInfo;
- memset(&osVerInfo, 0, sizeof(OSVERSIONINFO));
- osVerInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
- DWORD version = 0;
+ static DWORD osVersion = 0;
- if(GetVersionEx(&osVerInfo) == TRUE)
+ if(!osVersion)
{
- if(osVerInfo.dwPlatformId != VER_PLATFORM_WIN32_NT)
+ OSVERSIONINFO osVerInfo;
+ memset(&osVerInfo, 0, sizeof(OSVERSIONINFO));
+ osVerInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
+
+ if(GetVersionEx(&osVerInfo) == TRUE)
{
- throw "Ouuups: Not running under Windows NT. This is not supposed to happen!";
+ if(osVerInfo.dwPlatformId != VER_PLATFORM_WIN32_NT)
+ {
+ throw "Ouuups: Not running under Windows NT. This is not supposed to happen!";
+ }
+ osVersion = (DWORD)((osVerInfo.dwMajorVersion << 16) | (osVerInfo.dwMinorVersion & 0xffff));
}
- version = (DWORD)((osVerInfo.dwMajorVersion << 16) | (osVerInfo.dwMinorVersion & 0xffff));
}
- return version;
+ return osVersion;
+}
+
+/*
+ * Check if we are running under wine
+ */
+bool lamexp_detect_wine(void)
+{
+ static bool isWine = false;
+ static bool isWine_initialized = false;
+
+ if(!isWine_initialized)
+ {
+ QLibrary ntdll("ntdll.dll");
+ if(ntdll.load())
+ {
+ if(ntdll.resolve("wine_nt_to_unix_file_name") != NULL) isWine = true;
+ if(ntdll.resolve("wine_get_version") != NULL) isWine = true;
+ ntdll.unload();
+ }
+ isWine_initialized = true;
+ }
+
+ return isWine;
}
/*
bool lamexp_init_qt(int argc, char* argv[])
{
static bool qt_initialized = false;
- bool isWine = false;
typedef BOOL (WINAPI *SetDllDirectoryProc)(WCHAR *lpPathName);
//Don't initialized again, if done already
}
//Check for Wine
- QLibrary ntdll("ntdll.dll");
- if(ntdll.load())
+ if(lamexp_detect_wine())
{
- if(ntdll.resolve("wine_nt_to_unix_file_name") != NULL) isWine = true;
- if(ntdll.resolve("wine_get_version") != NULL) isWine = true;
- if(isWine) qWarning("It appears we are running under Wine, unexpected things might happen!\n");
- ntdll.unload();
+ qWarning("It appears we are running under Wine, unexpected things might happen!\n");
}
+
//Create Qt application instance and setup version info
QApplication *application = new QApplication(argc, argv);
application->setApplicationName("LameXP - Audio Encoder Front-End");
}
//Update console icon, if a console is attached
- if(g_lamexp_console_attached && !isWine)
+ if(g_lamexp_console_attached && (!lamexp_detect_wine()))
{
typedef DWORD (__stdcall *SetConsoleIconFun)(HICON);
QLibrary kernel32("kernel32.dll");
{
if(!FindFirstFileExInitialized)
{
- QLibrary Kernel32Lib("kernel32.dll");
- FindFirstFileExPtr = Kernel32Lib.resolve("FindFirstFileExW");
- DWORD osVersionNo = lamexp_get_os_version();
- FindFirstFileExInfoBasicOK = LAMEXP_MIN_OS_VER(osVersionNo, 6, 1);
+ QLibrary kernel32Lib("kernel32.dll");
+ if(kernel32Lib.load())
+ {
+ FindFirstFileExPtr = kernel32Lib.resolve("FindFirstFileExW");
+ DWORD osVersionNo = lamexp_get_os_version();
+ FindFirstFileExInfoBasicOK = LAMEXP_MIN_OS_VER(osVersionNo, 6, 1);
+ }
FindFirstFileExInitialized = true;
}
cpuSupport = m_cpuFeatures.x64 ? CPU_TYPE_X64_GEN : CPU_TYPE_X86_GEN;
}
- //Hack to disable x64 on the Windows 8 Developer Preview (not required anymore)
- //if(cpuSupport & CPU_TYPE_X64_ALL)
- //{
- // DWORD osVerNo = lamexp_get_os_version();
- // if((HIWORD(osVerNo) == 6) && (LOWORD(osVerNo) == 2))
- // {
- // qWarning("Windows 8 (x64) developer preview detected. Going to disable all x64 support!\n");
- // cpuSupport = (cpuSupport == CPU_TYPE_X64_SSE) ? CPU_TYPE_X86_SSE : CPU_TYPE_X86_GEN;
- // }
- //}
+ //Hack to disable x64 on Wine, as x64 binaries won't run under Wine (tested with Wine 1.4 under Ubuntu 12.04 x64)
+ if(cpuSupport & CPU_TYPE_X64_ALL)
+ {
+ //DWORD osVerNo = lamexp_get_os_version();
+ //if((HIWORD(osVerNo) == 6) && (LOWORD(osVerNo) == 2))
+ if(lamexp_detect_wine())
+ {
+ qWarning("Running under Wine on a 64-Bit system. Going to disable all x64 support!\n");
+ cpuSupport = (cpuSupport == CPU_TYPE_X64_SSE) ? CPU_TYPE_X86_SSE : CPU_TYPE_X86_GEN;
+ }
+ }
//Print selected CPU type
switch(cpuSupport)