Global.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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_bEnableLog;
  25. extern TCHAR g_szLogPath[MAX_PATH];
  26. extern COleDateTime g_lastTime;
  27. extern time_t g_time;
  28. extern FILE *gp_log_fp;
  29. // 回调Python里的函数;
  30. typedef void (*SENDPOWERKEY)();
  31. extern SENDPOWERKEY g_SendPowerKey;
  32. typedef struct _TLOG_{
  33. bool notify;
  34. string report_type;
  35. string report_data;
  36. __int64 datetime;
  37. }TLog, *pTLog;
  38. // 只需要一个记录即可,无需记录多个;
  39. extern TLog g_notify;
  40. extern std::vector<TLog> g_vtAbnormal;
  41. //////////////////////////////////////////////////////////////////////////
  42. // 全局函数;
  43. bool GetVersion(IN const TCHAR *fname, OUT WORD *pdwFileVersion, OUT WORD *pdwProductVerion);
  44. BOOL GetVersion(IN HMODULE hModule, OUT DWORD(&dwFVArray)[4], OUT DWORD(&dwPVArray)[4]);
  45. void WriteTextLog(const TCHAR *format, ...);
  46. void WritePythonLog(const TCHAR *msg);
  47. void ClosePythonLog();
  48. std::string EnCode_UTF8URL(IN const CHAR* pText);
  49. std::string &trim(std::string &str);
  50. // 字符串是否由数字、字母、符号组成;
  51. BOOL IsValidString(LPCTSTR lpszString);
  52. string DeCode_URLUNICODE(IN const CHAR* pURLText);
  53. BOOL Python27Dir();
  54. void GetResourceCfg();
  55. void Split(std::string str1, std::string str2, std::vector<std::string> &vt);
  56. };