MCPcopy Create free account
hub / github.com/BeneficialCode/WinArk / _tWinMain

Function _tWinMain

WinArk/WinArk.cpp:217–248  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

215}
216
217int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE /*hPrevInstance*/, LPTSTR lpstrCmdLine, int nCmdShow) {
218 g_hSingleInstMutex = ::CreateMutex(nullptr, FALSE, L"WinArkSingleInstanceMutex");
219 if (!::wcsstr(lpstrCmdLine, L"runas")) {
220 if (g_hSingleInstMutex) {
221 if (::GetLastError() == ERROR_ALREADY_EXISTS) {
222 MessageBox(nullptr, L"�����ظ�����!!!", L"Error", MB_ICONERROR);
223 return -1;
224 }
225 }
226 }
227 HRESULT hRes = ::CoInitializeEx(nullptr,COINIT_APARTMENTTHREADED|COINIT_DISABLE_OLE1DDE);
228 ATLASSERT(SUCCEEDED(hRes));
229 // add flags to support other controls
230 AtlInitCommonControls(ICC_BAR_CLASSES | ICC_BAR_CLASSES | ICC_LISTVIEW_CLASSES | ICC_TREEVIEW_CLASSES);
231
232 hRes = _Module.Init(NULL, hInstance);
233 ATLASSERT(SUCCEEDED(hRes));
234 ::SetPriorityClass(::GetCurrentProcess(), HIGH_PRIORITY_CLASS);
235 ::SetThreadPriority(::GetCurrentThread(), THREAD_PRIORITY_HIGHEST);
236 ::SetUnhandledExceptionFilter(SelfUnhandledExceptionFilter);
237
238 if (CheckInstall(lpstrCmdLine))
239 return 0;
240
241 int nRet = Run(lpstrCmdLine, nCmdShow);
242
243 _Module.Term();
244 ::CoUninitialize();
245 ::CloseHandle(g_hSingleInstMutex);
246
247 return nRet;
248}
249

Callers

nothing calls this directly

Calls 4

CheckInstallFunction · 0.85
RunFunction · 0.85
TermMethod · 0.80
InitMethod · 0.45

Tested by

no test coverage detected