static void print_version (void) { OSVERSIONINFOEX ver; BOOL ext; int is_win2k3_r2; ver.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX); if (!(ext = GetVersionEx ((OSVERSIONINFO *) &ver))) { ver.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); if (!GetVersionEx ((OSVERSIONINFO *) &ver)) report (R_FATAL, "Can't get OS version."); } xprintf (" bRunningUnderWine=%d\n", running_under_wine ()); xprintf (" bRunningOnVisibleDesktop=%d\n", running_on_visible_desktop ()); xprintf (" dwMajorVersion=%ld\n dwMinorVersion=%ld\n" " dwBuildNumber=%ld\n PlatformId=%ld\n szCSDVersion=%s\n", ver.dwMajorVersion, ver.dwMinorVersion, ver.dwBuildNumber, ver.dwPlatformId, ver.szCSDVersion); is_win2k3_r2 = GetSystemMetrics(SM_SERVERR2); if(is_win2k3_r2) xprintf(" R2 build number=%d\n", is_win2k3_r2); if (!ext) return; xprintf (" wServicePackMajor=%d\n wServicePackMinor=%d\n" " wSuiteMask=%d\n wProductType=%d\n wReserved=%d\n", ver.wServicePackMajor, ver.wServicePackMinor, ver.wSuiteMask, ver.wProductType, ver.wReserved); }
int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE /*hPrevInstance*/, LPTSTR lpstrCmdLine, int nCmdShow) { g_RunningUnderWine = running_under_wine(); #ifdef PPA_INCLUDE_CHECK_UPDATE if (_tcsstr(lpstrCmdLine, _T(PEERS_OPTION_NO_UPDATE)) == NULL) { string updatePath = Text::fromT(AutoUpdate::getUpdateTargetPath()); //TODO нужно еще exists(wstring), чтобы строку не преобразовывать if (File::exists(updatePath) && File::getSize(updatePath) > 0) { if (AutoUpdate::execute()) { return AutoUpdate::EXIT_TO_UPDATE; } } } //TODO else вывести сообщение если архив обновления еще есть. #endif #ifndef _DEBUG SingleInstance dcapp(_T("{DOMODC-AEE8350A-B49A-4753-AB4B-E55479A48351}")); #else SingleInstance dcapp(_T("{DOMODC-AEE8350A-B49A-4753-AB4B-E55479A48350}")); #endif // !SMT!-UI displaying abort message will disable generating exceptioninfo.txt signal(SIGABRT, AbortSignalHandler); #ifndef SMT_CUSTOM _set_abort_behavior(0, _WRITE_ABORT_MSG); #endif bool multipleInstances = false; bool magnet = false; bool delay = false; #ifdef _DEBUG g_DisableSplash = true; #endif if(_tcsstr(lpstrCmdLine, _T("/nologo"))!=NULL || _tcsstr(lpstrCmdLine, _T("/startup"))!=NULL) { g_DisableSplash = true; nCmdShow = SW_SHOWMINIMIZED; } if(_tcsstr(lpstrCmdLine, _T("/wine"))!=NULL) g_RunningUnderWine = true; if(_tcsstr(lpstrCmdLine, _T("/q"))!=NULL) multipleInstances = true; if(_tcsstr(lpstrCmdLine, _T("/magnet"))!=NULL) magnet = true; if(_tcsstr(lpstrCmdLine, _T("/c")) != NULL) { multipleInstances = true; delay = true; } if(dcapp.IsAnotherInstanceRunning()) { // Allow for more than one instance... bool multiple = false; if (multipleInstances == false && magnet == false) { if (::MessageBox(NULL, _T(APPNAME) _T(" уже запущена, или еще не закончила операцию закрытия...\nВы уверены, что хотите загрузить еще одну копию программы?"), _T(APPNAME) _T(" ") _T(VERSIONSTRING), MB_YESNO | MB_ICONQUESTION | MB_DEFBUTTON2 | MB_TOPMOST) == IDYES) { multiple = true; } } else { multiple = true; } if(delay == true) { Thread::sleep(2500); // let's put this one out for a break } if(multiple == false || magnet == true) { HWND hOther = NULL; EnumWindows(searchOtherInstance, (LPARAM)&hOther); if (hOther != NULL) { // pop up ::SetForegroundWindow(hOther); //if (IsIconic(hOther)) { // ::ShowWindow(hOther, SW_RESTORE); // !SMT!-f - disable, it unlocks password-protected instance //} sendCmdLine(hOther, lpstrCmdLine); } return FALSE; } } srand((unsigned) time(NULL)); // For SHBrowseForFolder, UPnP HRESULT hRes = ::CoInitializeEx(NULL, COINIT_APARTMENTTHREADED); // before next function call Util::initialize(); #ifdef _DEBUG InitSymInfo(Text::toT(Util::getDataPath()).c_str()); #endif LPTOP_LEVEL_EXCEPTION_FILTER pOldSEHFilter = NULL; pOldSEHFilter = SetUnhandledExceptionFilter(&DCUnhandledExceptionFilter); WSADATA wsaData; WSAStartup(MAKEWORD(2, 2), &wsaData); AtlInitCommonControls(ICC_COOL_CLASSES | ICC_BAR_CLASSES | ICC_LISTVIEW_CLASSES | ICC_TREEVIEW_CLASSES | ICC_PROGRESS_CLASS | ICC_STANDARD_CLASSES | ICC_TAB_CLASSES | ICC_UPDOWN_CLASS | ICC_USEREX_CLASSES); // add flags to support other controls hRes = _Module.Init(NULL, hInstance); ATLASSERT(SUCCEEDED(hRes)); /* !PPA! try { File f(WinUtil::getAppName(), File::READ, File::OPEN); TigerTree tth(TigerTree::calcBlockSize(f.getSize(), 1)); size_t n = 0; size_t n2 = DEBUG_BUFSIZE; while( (n = f.read(buf, n2)) > 0) { tth.update(buf, n); n2 = DEBUG_BUFSIZE; } tth.finalize(); strcpy(::tth, tth.getRoot().toBase32().c_str()); WinUtil::tth = Text::toT(::tth); } catch(const FileException&) { dcdebug("Failed reading exe\n"); } */ HINSTANCE hInstRich = ::LoadLibrary(_T("RICHED20.DLL")); int nRet = Run(lpstrCmdLine, nCmdShow); if ( hInstRich ) { ::FreeLibrary(hInstRich); } // Return back old VS SEH handler if (pOldSEHFilter != NULL) { SetUnhandledExceptionFilter(pOldSEHFilter); } _Module.Term(); ::CoUninitialize(); ::WSACleanup(); #ifdef _DEBUG UninitSymInfo(); #endif return nRet; }