int benchmark (void) { prep1((CHARTYPE *) search, 3); exec1((CHARTYPE *) buf, strlen(buf)); prep2((CHARTYPE *) search, 3); exec2((CHARTYPE *) buf, strlen(buf)); return 0; }
//--------------------------------------------------------------------------- // //--------------------------------------------------------------------------- int main(int /*argc*/, char const* /*argv*/ []) { // 二重起動防止用 auto deleteMutex = [](HANDLE hMutex){::CloseHandle(hMutex); }; std::unique_ptr<void, decltype(deleteMutex)> hMutex1 (::CreateMutex(nullptr, FALSE, L"ikHistory"), deleteMutex); // std::unique_ptr<void, decltype(::CloseHandle)> // hMutex1(::CreateMutex(nullptr, FALSE, L"ikHistory"), ::CloseHandle); // HANDLE hMutex = ::CreateMutex(NULL, FALSE, L"ikHistory"); if (::GetLastError() == ERROR_ALREADY_EXISTS) { return 0; } std::string const logName = "エラーログ.txt"; //DeleteFile(logName.c_str()); #ifndef _DEBUG try { #endif exec2(); #ifndef _DEBUG } catch (std::exception& e) { MessageBox(nullptr, util::toWideChar(e.what()).c_str(), L"エラーメッセージ", 0); std::ofstream fp(logName); fp << e.what() << "\n"; } catch (...) { MessageBox(nullptr, L"不明のエラー", L"エラーメッセージ", 0); } #endif }