common_api.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. #pragma once
  2. #include <map>
  3. #include <string>
  4. #include <Rpc.h>
  5. #include <vector>
  6. #include "ResDataObject.h"
  7. using namespace std;
  8. bool AddEnvPath(const char *pPath);
  9. bool DelEnvPath(const char* pPath);
  10. UINT64 GetDay(UINT64 TheTime);
  11. __time64_t GetCurrentRealTimeOfStk();
  12. int CompareTimeByDay(UINT64 Prev, UINT64 Cur);
  13. bool string_2_guid(const char *pstr, GUID &stGuid);
  14. bool guid_2_string(GUID &stGuid, string &str);
  15. bool SplitString(const char *pString, string args, vector<string> &nodes);
  16. bool SplitTo84422222222String(const char *pString, vector<string> &nodes);
  17. bool CreateFileDirectory(string &FullFilePath);
  18. string FormatstdString(const char *pcFormat, ...);
  19. bool getBusIdFromFilePath(const char *pFilePath,string &BusId);
  20. bool SplitDevicePath(const char *pDevicePath, vector<string> &nodes);
  21. bool MergeDevicePath(vector<string> &nodes, string &Devpath);
  22. string GetProcessDirectory();
  23. string GetFileTitle(string &fullpath);
  24. string GetFileName(string &fullpath);
  25. string & makeLowerStr(string & src);
  26. string GetFileDirectory(string &fullpath);
  27. bool FindSubVersionDirs(string rootDir, map<string, vector<string>>& dirlist);
  28. bool FindSortedSubFiles(string rootFile, vector<string> &filelist);
  29. void RawToHex(const char *pRaw, DWORD RawLen, string &Hex);
  30. string ReplaceSubString(string org, string &keystr, string &replacestr);
  31. string ReplaceFileTitle(string FilePath, string NewTitle);
  32. bool FindSubFiles(string rootDir, vector<string> &filelist, bool Recursive = true, string strWildcard = "*");
  33. template <class Type> bool StrToIntT(const char * str, Type *result)
  34. {
  35. Type value = 0;
  36. Type sign = 1;
  37. Type radix;
  38. if (str == NULL)
  39. {
  40. return false;
  41. }
  42. if (strlen(str) == 0)
  43. {
  44. return false;
  45. }
  46. if (*str == '-')
  47. {
  48. sign = -1;
  49. str++;
  50. }
  51. if (*str == '0' && (*(str + 1) == 'x' || *(str + 1) == 'X'))
  52. {
  53. radix = 16;
  54. str += 2;
  55. }
  56. //else if(*str == '0')
  57. //{
  58. // radix = 8;
  59. // str++;
  60. //}
  61. else
  62. {
  63. bool HitF = false;
  64. size_t Len = strlen(str);
  65. for (size_t i = 0; i < Len; i++)
  66. {
  67. if (str[i] >= '0' && str[i] <= '9')
  68. {
  69. continue;
  70. }
  71. HitF = true;
  72. break;
  73. }
  74. if (HitF)
  75. {
  76. radix = 16;
  77. }
  78. else
  79. {
  80. radix = 10;
  81. }
  82. }
  83. while (*str)
  84. {
  85. if (radix == 16)
  86. {
  87. if (*str >= '0' && *str <= '9')
  88. {
  89. value = value * radix + *str - '0';
  90. }
  91. else
  92. {
  93. if ((*str | 0x20) >= 'a' && (*str | 0x20) <= 'f')
  94. {
  95. value = value * radix + (*str | 0x20) - 'a' + 10;
  96. }
  97. else
  98. {
  99. return false;
  100. }
  101. }
  102. }
  103. else
  104. {
  105. value = value * radix + *str - '0';
  106. }
  107. str++;
  108. }
  109. *result = sign*value;
  110. return true;
  111. };
  112. class common_api
  113. {
  114. public:
  115. common_api(void);
  116. virtual ~common_api(void);
  117. HANDLE m_NotifyEvent;
  118. };
  119. using export_functions = std::tuple<string, DWORD, DWORD>;
  120. std::vector<export_functions> GetDllFunctionInfo(const char* moduleName);