utility.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. #ifndef __UITILITY__
  2. #define __UITILITY__
  3. #include <string>
  4. #include <vector>
  5. using namespace std;
  6. #ifndef _UNICODE
  7. typedef string TString;
  8. #else
  9. typedef wstring TString;
  10. #endif
  11. #pragma once
  12. namespace utilitySdk
  13. {
  14. __declspec(dllexport) BOOL IsValidDate(IN LPCTSTR lpDate);
  15. __declspec(dllexport) BOOL IsValidLunanrDate(IN LPCTSTR lpDate);
  16. __declspec(dllexport) BOOL IsValidLunanrDate(int lunar_year, int lunar_month, int lunar_day);
  17. __declspec(dllexport) BOOL IsValidSolarStrDate(LPCTSTR lpStrDate, BOOL bThisyear);
  18. __declspec(dllexport) BOOL IsValidSolarDate(CONST int &nSolarYear, CONST int &nSolarMonth, CONST int &nSolarDay);
  19. __declspec(dllexport) INT DayOfSolarYear(IN const int &nSolarYear,IN const int &nSolarMonth, IN const int &nSolarDay);
  20. __declspec(dllexport) CString GetLunarDate(IN const int &nSolarYear, IN const int &nSolarMonth, IN const int &nSolarDay); // 包含CString就不能使用静态库包含编译方式;
  21. __declspec(dllexport) INT GetLunarDate(OUT LPTSTR lpLunarDate,IN const int &nSolarYear, IN const int &nSolarMonth, IN const int &nSolarDay);
  22. __declspec(dllexport) CString LuanrToSolarDate(IN const int &nLunarYear, IN const int &nLunarMonth, IN const int &nLunarDay, BOOL bIsLeapMonth );
  23. __declspec(dllexport) BOOL LuanrToSolarDate(OUT LPTSTR lpSolarDate,IN const int &nLunarYear, IN const int &nLunarMonth, IN const int &nLunarDay, BOOL bIsLeapMonth );
  24. __declspec(dllexport) INT IsLeapMonth(IN const int &nLunarYear);
  25. __declspec(dllexport) BOOL GetFileVersion( IN HMODULE hModule, IN DWORD (&dwArray)[4]);
  26. __declspec(dllexport) BOOL GetFileVersionEx( IN LPCTSTR lpFileName, IN DWORD (&dwArray)[4] );
  27. __declspec(dllexport) BOOL GetProductVersion( IN HMODULE hModule, IN DWORD (&dwArray)[4]);
  28. __declspec(dllexport) BOOL GetProductVersionEx( IN LPCTSTR lpFileName, IN DWORD (&dwArray)[4] );
  29. __declspec(dllexport) BOOL GetDiskSpaceInfo(IN LPCTSTR lpRootPathName,IN OUT double &dTotalNum, IN OUT double &dFreeNum);
  30. __declspec(dllexport) DWORD FindProcess(IN LPCTSTR lpProName);
  31. __declspec(dllexport) BOOL FindProcess(IN LPCTSTR lpFilepath, OUT DWORD &dwProcessID);
  32. __declspec(dllexport) int FindAndCloseProcess(IN LPCTSTR lpProName);
  33. __declspec(dllexport) void GetErrorSysDescription(const DWORD &dwError, IN LPTSTR lpDescription, IN int const& nMaxLen);
  34. __declspec(dllexport) DWORD64 GetFolderSize(IN LPCTSTR lpPath, OUT DWORD *dwFiles = NULL, OUT DWORD *dwFolders = NULL);
  35. __declspec(dllexport) BOOL CreateDirectoryEx(IN LPCTSTR lpNewDirectory);
  36. __declspec(dllexport) BOOL IsValidpath(IN LPCTSTR lpPath);
  37. __declspec(dllexport) void DeleteDirectory(IN LPCTSTR lpDirectory);
  38. // 获取文件夹的修改时间;
  39. __declspec(dllexport) BOOL GetDirLastWriteTime(IN LPCTSTR lpDirName, OUT LPTSTR lpszString, IN CONST DWORD& dwSize);
  40. // 设置文件夹的修改时间;
  41. __declspec(dllexport) BOOL SetDirLastWriteTime();
  42. // 获取指定文件句柄的修改时间;
  43. __declspec(dllexport) BOOL GetLastWriteTime(IN HANDLE hFile, OUT LPTSTR lpszString, IN CONST DWORD& dwSize);
  44. // 设置指定文件夹的修改时间;
  45. __declspec(dllexport) BOOL SetFileLastWirteTime(IN LPCTSTR lpDirName, IN SYSTEMTIME &st);
  46. __declspec(dllexport) int match(IN CONST TString &sExt, IN CONST TString &sFile);
  47. __declspec(dllexport) TString getfilename(IN CONST TString &file);
  48. __declspec(dllexport) CString getfilename(IN CONST CString &file);
  49. __declspec(dllexport) TString lowercase(IN const TString &Str);
  50. __declspec(dllexport) TString uppercase(IN const TString &Str);
  51. __declspec(dllexport) BOOL CompareNoCase(IN TString& str1, IN TString& str2);
  52. __declspec(dllexport) BOOL IsStringExist(IN CString& str, IN CStringArray &tagAry);
  53. __declspec(dllexport) BOOL IsStringExist(IN TString& str, IN vector<TString> &tagVt);
  54. __declspec(dllexport) BOOL IsStringExistNoCase(IN CString& str, IN CStringArray &tagAry);
  55. __declspec(dllexport) BOOL IsStringExistNoCase(IN CONST TString& str, IN CStringArray &tagAry);
  56. __declspec(dllexport) BOOL IsStringExistNoCase(IN CONST TString& str, IN vector<TString> &tagVt);
  57. __declspec(dllexport) unsigned char *sha1(const unsigned char *msg,size_t size, unsigned char result[21]);
  58. __declspec(dllexport) unsigned char *sha1Hex(const unsigned char *msg, size_t size, unsigned char szHexResult[41]);
  59. // 是否合法路径;
  60. __declspec(dllexport) BOOL IsLegitimateDirectory(const CString &strDirectory);
  61. };
  62. #endif