Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

166 lines
4.6 KiB

  1. #ifndef _UTILS_H_
  2. #define _UTILS_H_
  3. #include <vss.h> // VSS_TIMESTAMP
  4. #include <vsmgmt.h>
  5. #include <mstask.h>
  6. #include <list>
  7. using namespace std;
  8. typedef struct _VSSUI_VOLUME
  9. {
  10. TCHAR pszVolumeName[MAX_PATH];
  11. TCHAR pszDisplayName[MAX_PATH];
  12. } VSSUI_VOLUME;
  13. typedef list<VSSUI_VOLUME *> VSSUI_VOLUME_LIST;
  14. typedef struct _VSSUI_SNAPSHOT
  15. {
  16. GUID idSnapshot;
  17. VSS_TIMESTAMP vssTimeStamp;
  18. } VSSUI_SNAPSHOT;
  19. typedef list<VSSUI_SNAPSHOT *> VSSUI_SNAPSHOT_LIST;
  20. typedef struct _VSSUI_DIFFAREA
  21. {
  22. TCHAR pszVolumeDisplayName[MAX_PATH];
  23. TCHAR pszDiffVolumeDisplayName[MAX_PATH];
  24. ULONGLONG llMaximumDiffSpace;
  25. ULONGLONG llUsedDiffSpace;
  26. } VSSUI_DIFFAREA;
  27. typedef list<VSSUI_DIFFAREA *> VSSUI_DIFFAREA_LIST;
  28. // MACROS
  29. #define TWO_WHACKS(p) ((p) && lstrlen(p) > 1 && *(p) == _T('\\') && *((p)+1) == _T('\\'))
  30. #define MINIMUM_DIFF_LIMIT (100 * g_llMB)
  31. #define MINIMUM_DIFF_LIMIT_MB 100
  32. #define MINIMUM_DIFF_LIMIT_DELTA_MB 50
  33. // globals
  34. extern ULONGLONG g_llKB;
  35. extern ULONGLONG g_llMB;
  36. extern ULONGLONG g_llGB;
  37. HRESULT
  38. AddLVColumns(
  39. IN const HWND hwndListBox,
  40. IN const INT iStartingResourceID,
  41. IN const UINT uiColumns
  42. );
  43. LPARAM GetListViewItemData(
  44. IN HWND hwndList,
  45. IN int index
  46. );
  47. int mylstrncmpi(
  48. IN LPCTSTR lpString1,
  49. IN LPCTSTR lpString2,
  50. IN UINT cchCount
  51. );
  52. HRESULT FindScheduledTimewarpTask(
  53. IN ITaskScheduler* i_piTS,
  54. IN LPCTSTR i_pszVolumeName,
  55. OUT ITask** o_ppiTask,
  56. OUT PTSTR* o_ppszTaskName = NULL
  57. );
  58. HRESULT GetScheduledTimewarpTaskStatus(
  59. IN ITask* i_piTask,
  60. OUT BOOL* o_pbEnabled,
  61. OUT SYSTEMTIME* o_pstNextRunTime
  62. );
  63. HRESULT CreateDefaultEnableSchedule(
  64. IN ITaskScheduler* i_piTS,
  65. IN LPCTSTR i_pszComputer,
  66. IN LPCTSTR i_pszVolumeDisplayName,
  67. IN LPCTSTR i_pszVolumeName,
  68. OUT ITask** o_ppiTask,
  69. OUT PTSTR* o_pszTaskName = NULL
  70. );
  71. HRESULT DeleteOneScheduledTimewarpTasks(
  72. IN ITaskScheduler* i_piTS,
  73. IN LPCTSTR i_pszComputer,
  74. IN LPCTSTR i_pszTaskName
  75. );
  76. HRESULT DeleteAllScheduledTimewarpTasks(
  77. IN ITaskScheduler* i_piTS,
  78. IN LPCTSTR i_pszComputer,
  79. IN LPCTSTR i_pszVolumeName,
  80. IN BOOL i_bDeleteDisabledOnesOnly
  81. );
  82. HRESULT VssTimeToSystemTime(
  83. IN VSS_TIMESTAMP* i_pVssTime,
  84. OUT SYSTEMTIME* o_pSystemTime
  85. );
  86. HRESULT SystemTimeToString(
  87. IN SYSTEMTIME* i_pSystemTime,
  88. OUT PTSTR o_pszText,
  89. IN OUT DWORD* io_pdwSize
  90. );
  91. HRESULT DiskSpaceToString(
  92. IN ULONGLONG i_llDiskSpace,
  93. OUT PTSTR o_pszText,
  94. IN OUT DWORD* io_pdwSize
  95. );
  96. HRESULT GetVolumeSpace(
  97. IN IVssDifferentialSoftwareSnapshotMgmt* piDiffSnapMgmt,
  98. IN LPCTSTR i_pszVolumeDisplayName,
  99. OUT ULONGLONG* o_pllVolumeTotalSpace = NULL,
  100. OUT ULONGLONG* o_pllVolumeFreeSpace = NULL
  101. );
  102. HRESULT GetDiffAreaInfo(
  103. IN IVssDifferentialSoftwareSnapshotMgmt* piDiffSnapMgmt,
  104. IN VSSUI_VOLUME_LIST* pVolumeList,
  105. IN LPCTSTR pszVolumeName,
  106. OUT VSSUI_DIFFAREA* pDiffArea
  107. );
  108. HRESULT GetVolumesSupportedForDiffArea(
  109. IN IVssDifferentialSoftwareSnapshotMgmt* piDiffSnapMgmt,
  110. IN LPCTSTR pszVolumeDisplayName,
  111. IN OUT VSSUI_VOLUME_LIST* pVolumeList
  112. );
  113. PTSTR GetDisplayName(VSSUI_VOLUME_LIST *pVolumeList, LPCTSTR pszVolumeName);
  114. PTSTR GetVolumeName(VSSUI_VOLUME_LIST *pVolumeList, LPCTSTR pszDisplayName);
  115. void FreeVolumeList(VSSUI_VOLUME_LIST* pList);
  116. void FreeSnapshotList(VSSUI_SNAPSHOT_LIST *pList);
  117. void FreeDiffAreaList(VSSUI_DIFFAREA_LIST* pList);
  118. HRESULT GetSystem32Directory(
  119. IN LPCTSTR i_pszComputer,
  120. OUT PTSTR o_pszSystem32Directory,
  121. IN OUT DWORD* o_pdwSize
  122. );
  123. void GetMsg(
  124. OUT CString& strMsg,// OUT: the message
  125. DWORD dwErr, // IN: Error code from GetLastError()
  126. UINT wIdString, // IN: String resource Id
  127. ...); // IN: Optional arguments
  128. INT DoErrMsgBox(
  129. HWND hwndParent, // IN: Parent of the dialog box
  130. UINT uType, // IN: style of message box
  131. DWORD dwErr, // IN: Error code from GetLastError()
  132. UINT wIdString, // IN: String resource Id
  133. ...); // IN: Optional arguments
  134. BOOL IsPostW2KServer(LPCTSTR pszComputer);
  135. #endif // _UTILS_H_