SProxy.cpp 4.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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. bool startWisth(const std::wstring& mainstr, const std::wstring& substr)
  10. {
  11. return mainstr.find(substr) == 0 ? 1 : 0;
  12. }
  13. int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE /*hPrevInstance*/, LPTSTR lpstrCmdLine, int /*nCmdShow*/)
  14. {
  15. HRESULT hRes = OleInitialize(NULL);
  16. SASSERT(SUCCEEDED(hRes));
  17. int nRet = 0;
  18. new CApp();
  19. new CProcessManager();
  20. CApp::getSingletonPtr()->Init();
  21. CApp::getSingletonPtr()->SetMethod(hInstance);
  22. CApp::getSingletonPtr()->ChkeAndSetDtaPath();
  23. if (!CApp::getSingletonPtr()->CheckOnlyOneInstance())
  24. {
  25. std::wstring pmPrefix = L"--pm=";
  26. std::wstring cmdLine(lpstrCmdLine);
  27. if (startWisth(cmdLine, pmPrefix))
  28. return CProcessManager::getSingletonPtr()->SubProcess(cmdLine.substr(pmPrefix.size()));
  29. }
  30. CreateDirectoryIgnoreExist(CApp::getSingletonPtr()->GetDataPath().c_str());
  31. CApp::getSingletonPtr()->CheckOnlyOneInstance();
  32. PortableModeUtil::SetAppId();
  33. /**/
  34. CProcessManager::getSingletonPtr()->SetInsTanCe(hInstance);
  35. CSouiLoader Loader(hInstance);
  36. InitSystemRes(Loader.GetApp(), Loader.GetComMgr());
  37. InitUserRes(Loader.GetApp(), Loader.GetComMgr());
  38. new CTool();
  39. new SNotifyCenter();
  40. new CManageNetWork();
  41. TCHAR szCurrentDir[MAX_PATH] = { 0 };
  42. GetModuleFileName(NULL, szCurrentDir, sizeof(szCurrentDir));
  43. LPTSTR lpInsertPos = _tcsrchr(szCurrentDir, _T('\\'));
  44. _tcscpy(lpInsertPos + 1, _T("\0"));
  45. SetCurrentDirectory(szCurrentDir);
  46. nRet = Run<CLoginDlg>(Loader.GetApp());
  47. if (CApp::getSingletonPtr()->GetOut() == 1)
  48. {
  49. nRet = Run<CMainDlg>(Loader.GetApp());
  50. }
  51. delete CTool::getSingletonPtr();
  52. delete SNotifyCenter::getSingletonPtr();
  53. delete CManageNetWork::getSingletonPtr();
  54. delete CProcessManager::getSingletonPtr();
  55. delete CApp::getSingletonPtr();
  56. OleUninitialize();
  57. return nRet;
  58. }