Utils.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. /**************************************************************************************************
  2. 版本所有(C), 2021-2022, 北京普达迪泰
  3. ***************************************************************************************************
  4. 文 件 名:Common.h
  5. 版 本 号: 1.00初版
  6. 作 者: HYF
  7. 生成日期:2021-12-20
  8. 最近修改:
  9. 功能描述: 公共函數
  10. 函数列表:
  11. 修改历史:
  12. 1.日 期 : 2012-3-20
  13. 作 者 : HYF
  14. 修改内容 : 创建文件
  15. **************************************************************************************************/
  16. #pragma once
  17. #include <afx.h>
  18. #include <string>
  19. #include "pch.h"
  20. using namespace std;
  21. class Utils
  22. {
  23. public:
  24. Utils(void);
  25. ~Utils(void);
  26. // 获取运行目录路径
  27. static CString GetExecDir(void);
  28. // 获取Web访问目录路径
  29. static CString GetLocalUrlDir(void);
  30. // 文件是否存在
  31. static BOOL IsFileExist(LPCTSTR lpFileName);
  32. // 目录是否存在
  33. BOOL DirectoryExists(LPCTSTR szFilePath);
  34. // 获取时间戳
  35. static INT64 GetCurrentTimeStamp();
  36. // 北京时间字串转时间戳
  37. static INT64 StringToTimeStamp(CString strInputTime);
  38. // 时间戳转北京时间字串
  39. static CString TimeStampToString(INT64 timestamp);
  40. // ANSI转UTF8
  41. static std::string ConverANSI2UTF8(const std::string & str);
  42. // ANSI转UNICODE
  43. static std::wstring ConverANSI2Unicode(const std::string str);
  44. // UTF8转UNICODE
  45. static std::wstring ConverUTF82Unicode(const std::string str);
  46. // UNICODE转UTF8
  47. static std::string ConverUnicode2UTF8(const std::wstring str);
  48. // UNICODE转ANSI
  49. static std::string ConverUnicode2ANSI(const std::wstring str);
  50. // UTF8转ANSI
  51. static std::string ConverUTF82ANSI(const std::string str);
  52. // 删除文件夹
  53. static BOOL DeleteFolder(const CString& strDirName);
  54. static BOOL SHDeleteFolder(const CString &szDir);
  55. // 移动文件夹
  56. static void MoveFolder(const CString& szSrc, const CString& szDes);
  57. // 创建自定义消息报文
  58. static DMSResponse* DMS_CreateMsg();
  59. // 释放消息
  60. static void DMS_FreeMsg(DMSResponse *pMsg);
  61. // IP地址转换:字符串转DWORD
  62. static DWORD IP_STR2DW(LPCTSTR szIP);
  63. // 字符串分割成字符串数组
  64. static int StrSplit(const CString& strLine, char split, CStringArray& strArray);
  65. static int StrSplit(const char *szLine, int iLen, char split, CStringArray& strArray);
  66. static int StrSplit(const CString& strLine, LPCTSTR split, CStringArray& strArray);
  67. static BOOL LoadImageFromResource(CImage *pImage, UINT nResID, LPCTSTR lpTyp);
  68. };