int APIENTRY WinMain(HINSTANCE, HINSTANCE, LPSTR, int) { try { // Start Win32++ CDialogApp theApp; // Run the application return theApp.Run(); } // catch all exceptions inherited from std::exception catch (std::exception &e) { // Process the exception and quit e.what(); return -1; } }
int APIENTRY WinMain(HINSTANCE, HINSTANCE, LPSTR, int) { try { // Start Win32++ CDialogApp theApp; // Run the application return theApp.Run(); } // catch all unhandled CException types catch (const CException &e) { // Display the exception and quit MessageBox(NULL, e.GetText(), A2T(e.what()), MB_ICONERROR); return -1; } }
INT WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int iCmdShow) { TCHAR szBuf[MAX_STRING_SIZE]; ::LoadString(hInstance, IDW_MAIN, szBuf, MAX_STRING_SIZE -1); HWND hWnd = FindWindow(szBuf, NULL); // If application is already running, restore it and quit if (hWnd) { SetForegroundWindow ((HWND)(((DWORD)hWnd) | 0x01)); TRACE("Application Already running"); return -1; } // The one and only CDialogApp object CDialogApp theApp; //Process the window messages return theApp.Run(); }