12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788 |
- // dui-demo.cpp : main source file
- //
- #include "stdafx.h"
- #include "MainDlg.h"
- #include "LoginDlg.h"
- #include "SouiInit.h"
- #include "CApp.h"
- #include "CTool.h"
- bool startWisth(const std::wstring& mainstr, const std::wstring& substr)
- {
- return mainstr.find(substr) == 0 ? 1 : 0;
- }
- int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE /*hPrevInstance*/, LPTSTR lpstrCmdLine, int /*nCmdShow*/)
- {
- HRESULT hRes = OleInitialize(NULL);
- SASSERT(SUCCEEDED(hRes));
-
-
- int nRet = 0;
- new CApp();
- new CProcessManager();
- CApp::getSingletonPtr()->Init();
- CApp::getSingletonPtr()->SetMethod(hInstance);
- CApp::getSingletonPtr()->ChkeAndSetDtaPath();
-
-
- if (!CApp::getSingletonPtr()->CheckOnlyOneInstance())
- {
- std::wstring pmPrefix = L"--pm=";
- std::wstring cmdLine(lpstrCmdLine);
- if (startWisth(cmdLine, pmPrefix))
- return CProcessManager::getSingletonPtr()->SubProcess(cmdLine.substr(pmPrefix.size()));
- }
- CreateDirectoryIgnoreExist(CApp::getSingletonPtr()->GetDataPath().c_str());
- CApp::getSingletonPtr()->CheckOnlyOneInstance();
- PortableModeUtil::SetAppId();
- /**/
- CProcessManager::getSingletonPtr()->SetInsTanCe(hInstance);
- CSouiLoader Loader(hInstance);
- InitSystemRes(Loader.GetApp(), Loader.GetComMgr());
- InitUserRes(Loader.GetApp(), Loader.GetComMgr());
- new CTool();
- new SNotifyCenter();
- new CManageNetWork();
- 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 CTool::getSingletonPtr();
- delete SNotifyCenter::getSingletonPtr();
- delete CManageNetWork::getSingletonPtr();
- CProcessManager::getSingletonPtr()->SendStopSignal();
- WaitForSingleObject(CProcessManager::getSingletonPtr()->GetClashProcessInfo().hProcess, 3000);
- CProcessManager::getSingletonPtr()->Stop();
- delete CProcessManager::getSingletonPtr();
- delete CApp::getSingletonPtr();
- OleUninitialize();
- return nRet;
- }
|