
#pragma once
#include <stdio.h>
#include <locale.h>
#include <stdlib.h>
#include <time.h> //或者 #include <ctime>
#include <io.h>
#pragma comment(lib,"version.lib")
#include "../cJson/cJSON.h"
#include <vector>
#include <string>
using namespace std;
namespace Global
{
	//////////////////////////////////////////////////////////////////////////
	// 全局变量;
	extern TCHAR g_szCurModuleDir[MAX_PATH];
	extern TCHAR g_szCurModulePath[MAX_PATH];
	extern TCHAR g_szFna[MAX_PATH];
	extern TCHAR g_szConfig[MAX_PATH];
	extern TCHAR g_szPython27Dir[MAX_PATH];
	extern TCHAR g_szTVPort[MAX_PATH];
	extern TCHAR g_szTVReboot[MAX_PATH];
	extern TCHAR g_szTVShutdown[MAX_PATH];
	extern BOOL  g_bWatchTVPort;

	extern bool g_bEnableLog;
	extern TCHAR g_szLogPath[MAX_PATH];
	extern COleDateTime g_lastTime;
	extern time_t g_time;
	extern FILE *gp_log_fp;

	// 回调Python里的函数;
	typedef void (*SENDPOWERKEY)();
	extern SENDPOWERKEY g_SendPowerKey;

	typedef struct _TLOG_{
		bool notify;
		string report_type;
		string report_data;
		__int64 datetime;
	}TLog, *pTLog;

	// 只需要一个记录即可,无需记录多个;
	extern TLog g_notify;
	extern std::vector<TLog> g_vtAbnormal;

	//////////////////////////////////////////////////////////////////////////
	// 全局函数;
	bool GetVersion(IN const TCHAR *fname, OUT WORD *pdwFileVersion, OUT WORD *pdwProductVerion);
	BOOL GetVersion(IN HMODULE hModule, OUT DWORD(&dwFVArray)[4], OUT DWORD(&dwPVArray)[4]);
	void WriteTextLog(const TCHAR *format, ...);
	void WritePythonLog(const TCHAR *msg);
	void ClosePythonLog();
	std::string EnCode_UTF8URL(IN const CHAR* pText);
	std::string &trim(std::string &str);
	// 字符串是否由数字、字母、符号组成;
	BOOL IsValidString(LPCTSTR lpszString);
	string DeCode_URLUNICODE(IN const CHAR* pURLText);
	BOOL Python27Dir();
	void GetResourceCfg();
	void Split(std::string str1, std::string str2, std::vector<std::string> &vt);
};
