Global.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. #pragma once
  2. #include <stdio.h>
  3. #include <locale.h>
  4. #include <stdlib.h>
  5. #include <time.h> //或者 #include <ctime>
  6. #include <io.h>
  7. #pragma comment(lib,"version.lib")
  8. #include "../cJson/cJSON.h"
  9. #include <vector>
  10. #include <string>
  11. using namespace std;
  12. namespace Global
  13. {
  14. //////////////////////////////////////////////////////////////////////////
  15. // 全局变量;
  16. extern TCHAR g_szCurModuleDir[MAX_PATH];
  17. extern TCHAR g_szCurModulePath[MAX_PATH];
  18. extern TCHAR g_szFna[MAX_PATH];
  19. extern TCHAR g_szConfig[MAX_PATH];
  20. extern TCHAR g_szPython27Dir[MAX_PATH];
  21. extern TCHAR g_szTVPort[MAX_PATH];
  22. extern TCHAR g_szTVReboot[MAX_PATH];
  23. extern TCHAR g_szTVShutdown[MAX_PATH];
  24. extern BOOL g_bWatchTVPort;
  25. extern bool g_bEnableLog;
  26. extern TCHAR g_szLogPath[MAX_PATH];
  27. extern COleDateTime g_lastTime;
  28. extern time_t g_time;
  29. extern FILE *gp_log_fp;
  30. // 回调Python里的函数;
  31. typedef void (*SENDPOWERKEY)();
  32. extern SENDPOWERKEY g_SendPowerKey;
  33. typedef struct _TLOG_{
  34. bool notify;
  35. string report_type;
  36. string report_data;
  37. __int64 datetime;
  38. }TLog, *pTLog;
  39. // 只需要一个记录即可,无需记录多个;
  40. extern TLog g_notify;
  41. extern std::vector<TLog> g_vtAbnormal;
  42. //////////////////////////////////////////////////////////////////////////
  43. // 全局函数;
  44. bool GetVersion(IN const TCHAR *fname, OUT WORD *pdwFileVersion, OUT WORD *pdwProductVerion);
  45. BOOL GetVersion(IN HMODULE hModule, OUT DWORD(&dwFVArray)[4], OUT DWORD(&dwPVArray)[4]);
  46. void WriteTextLog(const TCHAR *format, ...);
  47. void WritePythonLog(const TCHAR *msg);
  48. void ClosePythonLog();
  49. std::string EnCode_UTF8URL(IN const CHAR* pText);
  50. std::string &trim(std::string &str);
  51. // 字符串是否由数字、字母、符号组成;
  52. BOOL IsValidString(LPCTSTR lpszString);
  53. string DeCode_URLUNICODE(IN const CHAR* pURLText);
  54. BOOL Python27Dir();
  55. void GetResourceCfg();
  56. void Split(std::string str1, std::string str2, std::vector<std::string> &vt);
  57. };