1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374 |
- // dui-demo.cpp : main source file
- //
- #include "stdafx.h"
- #include "MainDlg.h"
- #include "LoginDlg.h"
- #include "SouiInit.h"
- #include "CApp.h"
- #include "CTool.h"
-
- int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE /*hPrevInstance*/, LPTSTR lpstrCmdLine, int /*nCmdShow*/)
- {
- HRESULT hRes = OleInitialize(NULL);
- SASSERT(SUCCEEDED(hRes));
-
-
- int nRet = 0;
- new CApp();
- CApp::getSingletonPtr()->Init();
- CApp::getSingletonPtr()->SetMethod(hInstance);
- CApp::getSingletonPtr()->ChkeAndSetDtaPath();
-
- if (!CApp::getSingletonPtr()->CheckOnlyOneInstance())
- {
- std::wstring pmPrefix = L"--pm=";
- std::wstring_view cmdLine(lpstrCmdLine);
- if (pmPrefix._Starts_with(cmdLine))
- return ProcessManager::SubProcess(cmdLine.substr(pmPrefix.size()));
- }
- CreateDirectoryIgnoreExist(CApp::getSingletonPtr()->GetDataPath().c_str());
- CApp::getSingletonPtr()->CheckOnlyOneInstance();
- PortableModeUtil::SetAppId();
- /**/
- ProcessManager::SetInsTanCe(hInstance);
- CSouiLoader Loader(hInstance);
- InitSystemRes(Loader.GetApp(), Loader.GetComMgr());
- InitUserRes(Loader.GetApp(), Loader.GetComMgr());
- new CTool();
- new SNotifyCenter();
- TCHAR szCurrentDir[MAX_PATH] = { 0 };
- GetModuleFileName(NULL, szCurrentDir, sizeof(szCurrentDir));
- LPTSTR lpInsertPos = _tcsrchr(szCurrentDir, _T('\\'));
-
- _tcscpy(lpInsertPos + 1, _T("\0"));
-
- SetCurrentDirectory(szCurrentDir);
- nRet = Run<CLoginDlg>(Loader.GetApp());
- if (CApp::getSingletonPtr()->GetOut() == 1)
- {
- nRet = Run<CMainDlg>(Loader.GetApp());
- }
- delete CApp::getSingletonPtr();
- delete CTool::getSingletonPtr();
- delete SNotifyCenter::getSingletonPtr();
-
- OleUninitialize();
- return nRet;
- }
|