zhipuzi_pos_windows.cpp 2.3 KB

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