zhipuzi_pos_windows.cpp 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. #include "pch/pch.h"
  2. #include "wnd/CLoginWnd.h"
  3. #include <curl/curl.h>
  4. #include "tool/CAppEnv.h"
  5. //用于从zip读取资源
  6. LPBYTE g_lpResourceZIPBuffer = NULL;
  7. int APIENTRY wWinMain(_In_ HINSTANCE hInstance,
  8. _In_opt_ HINSTANCE hPrevInstance,
  9. _In_ LPWSTR lpCmdLine,
  10. _In_ int nCmdShow)
  11. {
  12. //如果进程已经在运行了,直接返回,也就是不支持进程多开
  13. if (CSystem::IsAppRunning())
  14. {
  15. return -1;
  16. }
  17. //初始化日志,这个一定要放在这里,才不会被析构掉
  18. CLewaimaiLog log;
  19. log.Init();
  20. //初始化所有配置,启动所有异步worker
  21. CAppEnv app;
  22. app.Start();
  23. //开始展示窗口
  24. CPaintManagerUI::SetInstance(hInstance);
  25. #ifdef NDEBUG
  26. //CPaintManagerUI::SetResourcePath(CPaintManagerUI::GetInstancePath() + _T("skin"));
  27. //CPaintManagerUI::SetResourceZip(_T("skin.zpz"));
  28. //从资源中加载zip
  29. HRSRC hResource = ::FindResource(CPaintManagerUI::GetResourceDll(), MAKEINTRESOURCE(IDR_ZIPRES1), _T("ZIPRES"));
  30. if (hResource == NULL)
  31. {
  32. return 0L;
  33. }
  34. DWORD dwSize = 0;
  35. HGLOBAL hGlobal = ::LoadResource(CPaintManagerUI::GetResourceDll(), hResource);
  36. if (hGlobal == NULL)
  37. {
  38. ::FreeResource(hResource);
  39. return 0L;
  40. }
  41. dwSize = ::SizeofResource(CPaintManagerUI::GetResourceDll(), hResource);
  42. if (dwSize == 0)
  43. {
  44. return 0L;
  45. }
  46. g_lpResourceZIPBuffer = new BYTE[dwSize];
  47. if (g_lpResourceZIPBuffer != NULL)
  48. {
  49. ::CopyMemory(g_lpResourceZIPBuffer, (LPBYTE)::LockResource(hGlobal), dwSize);
  50. }
  51. ::FreeResource(hResource);
  52. CPaintManagerUI::SetResourceZip(g_lpResourceZIPBuffer, dwSize);
  53. #else
  54. //debug模式下
  55. CPaintManagerUI::SetResourcePath(CPaintManagerUI::GetInstancePath() + _T("skin"));
  56. #endif
  57. HRESULT Hr = ::CoInitialize(NULL);
  58. if(FAILED(Hr))
  59. {
  60. return 0;
  61. }
  62. //先显示登录窗口
  63. CLoginWnd* pLogin = new CLoginWnd();
  64. if(pLogin == NULL)
  65. {
  66. return 0;
  67. }
  68. pLogin->Create(NULL, _T("智铺子收银软件登录"), UI_WNDSTYLE_DIALOG, 0, 0, 0, 0, 0, NULL);
  69. pLogin->SetIcon(IDI_ICON_DUILIB);
  70. pLogin->CenterWindow();
  71. pLogin->ShowWindow(true);
  72. CPaintManagerUI::MessageLoop();
  73. ::CoUninitialize();
  74. //销毁一些环境
  75. app.Stop();
  76. return 0;
  77. }