SProxy.cpp 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. // dui-demo.cpp : main source file
  2. //
  3. #include "stdafx.h"
  4. #include "MainDlg.h"
  5. #include "LoginDlg.h"
  6. #include "SouiInit.h"
  7. #include "CApp.h"
  8. #include "CTool.h"
  9. int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE /*hPrevInstance*/, LPTSTR lpstrCmdLine, int /*nCmdShow*/)
  10. {
  11. HRESULT hRes = OleInitialize(NULL);
  12. SASSERT(SUCCEEDED(hRes));
  13. int nRet = 0;
  14. new CApp();
  15. CApp::getSingletonPtr()->Init();
  16. CApp::getSingletonPtr()->SetMethod(hInstance);
  17. CApp::getSingletonPtr()->ChkeAndSetDtaPath();
  18. if (!CApp::getSingletonPtr()->CheckOnlyOneInstance())
  19. {
  20. std::wstring pmPrefix = L"--pm=";
  21. std::wstring_view cmdLine(lpstrCmdLine);
  22. if (pmPrefix._Starts_with(cmdLine))
  23. return ProcessManager::SubProcess(cmdLine.substr(pmPrefix.size()));
  24. }
  25. CreateDirectoryIgnoreExist(CApp::getSingletonPtr()->GetDataPath().c_str());
  26. CApp::getSingletonPtr()->CheckOnlyOneInstance();
  27. PortableModeUtil::SetAppId();
  28. /**/
  29. ProcessManager::SetInsTanCe(hInstance);
  30. CSouiLoader Loader(hInstance);
  31. InitSystemRes(Loader.GetApp(), Loader.GetComMgr());
  32. InitUserRes(Loader.GetApp(), Loader.GetComMgr());
  33. new CTool();
  34. new SNotifyCenter();
  35. TCHAR szCurrentDir[MAX_PATH] = { 0 };
  36. GetModuleFileName(NULL, szCurrentDir, sizeof(szCurrentDir));
  37. LPTSTR lpInsertPos = _tcsrchr(szCurrentDir, _T('\\'));
  38. _tcscpy(lpInsertPos + 1, _T("\0"));
  39. SetCurrentDirectory(szCurrentDir);
  40. nRet = Run<CLoginDlg>(Loader.GetApp());
  41. if (CApp::getSingletonPtr()->GetOut() == 1)
  42. {
  43. nRet = Run<CMainDlg>(Loader.GetApp());
  44. }
  45. delete CApp::getSingletonPtr();
  46. delete CTool::getSingletonPtr();
  47. delete SNotifyCenter::getSingletonPtr();
  48. OleUninitialize();
  49. return nRet;
  50. }