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.

207 lines
6.8 KiB

  1. /////////////////////////////////////////////////////////////////////
  2. //
  3. // Utils.h
  4. //
  5. // General-purpose windows utilities routines.
  6. //
  7. // HISTORY
  8. // t-danmo 96.09.22 Creation.
  9. //
  10. /////////////////////////////////////////////////////////////////////
  11. #ifndef __UTILS_H__
  12. #define __UTILS_H__
  13. extern HINSTANCE g_hInstanceSave; // Instance handle of the DLL (initialized during CFileMgmtComponent::Initialize)
  14. HRESULT
  15. GetErrorMessage(
  16. IN DWORD i_dwError,
  17. OUT CString& cstrErrorMsg
  18. );
  19. void mystrtok(
  20. IN LPCTSTR pszString,
  21. IN OUT int* pnIndex, // start from 0
  22. IN LPCTSTR pszCharSet,
  23. OUT CString& strToken
  24. );
  25. BOOL IsInvalidSharename(LPCTSTR psz);
  26. /////////////////////////////////////////////////////////////////////
  27. // Structure used to add items to a listbox or combobox.
  28. //
  29. struct TStringParamEntry // spe
  30. {
  31. UINT uStringId; // Id of the resource string
  32. LPARAM lItemData; // Optional parameter for the string (stored in lParam field)
  33. };
  34. void ComboBox_FlushContent(HWND hwndCombo);
  35. BOOL ComboBox_FFill(
  36. const HWND hwndCombo, // IN: Handle of the combobox
  37. const TStringParamEntry rgzSPE[], // IN: SPE aray zero terminated
  38. const LPARAM lItemDataSelect); // IN: Which item to select
  39. LPARAM ComboBox_GetSelectedItemData(HWND hwndComboBox);
  40. HWND HGetDlgItem(HWND hdlg, INT nIdDlgItem);
  41. void SetDlgItemFocus(HWND hdlg, INT nIdDlgItem);
  42. void EnableDlgItem(HWND hdlg, INT nIdDlgItem, BOOL fEnable);
  43. void EnableDlgItemGroup(
  44. HWND hdlg,
  45. const UINT rgzidCtl[],
  46. BOOL fEnable);
  47. void ShowDlgItemGroup(
  48. HWND hdlg,
  49. const UINT rgzidCtl[],
  50. BOOL fShowAll);
  51. TCHAR * Str_PchCopyChN(
  52. TCHAR * szDst, // OUT: Destination buffer
  53. CONST TCHAR * szSrc, // IN: Source buffer
  54. TCHAR chStop, // IN: Character to stop the copying
  55. INT cchDstMax); // IN: Length of the output buffer
  56. INT Str_RemoveSubStr(
  57. WCHAR * szBuf, // IN OUT: Source/Destination buffer
  58. CONST WCHAR * szToken); // IN: Token to remove
  59. TCHAR * PchParseCommandLine(
  60. CONST TCHAR szFullCommand[], // IN: Full command line
  61. TCHAR szBinPath[], // OUT: Path of the executable binary
  62. INT cchBinPathBuf); // IN: Size of the buffer
  63. void TrimString(CString& rString);
  64. /////////////////////////////////////////////////////////////////////
  65. struct TColumnHeaderItem
  66. {
  67. UINT uStringId; // Resource Id of the string
  68. INT nColWidth; // % of total width of the column (0 = autowidth, -1 = fill rest of space)
  69. };
  70. void ListView_AddColumnHeaders(
  71. HWND hwndListview,
  72. const TColumnHeaderItem rgzColumnHeader[]);
  73. int ListView_InsertItemEx(
  74. HWND hwndListview,
  75. CONST LV_ITEM * pLvItem);
  76. // 581272 JonN 2002/04/03 With this change, this function returns an
  77. // array of pointers to strings, but does not allocate the strings
  78. // themselves. pgrsz must not be deleted before the return value.
  79. LPTSTR * PargzpszFromPgrsz(CONST LPCTSTR pgrsz, INT * pcStringCount);
  80. BOOL UiGetFileName(HWND hwnd, TCHAR szFileName[], INT cchBufferLength);
  81. //
  82. // Printf-type functions
  83. //
  84. TCHAR * PaszLoadStringPrintf(UINT wIdString, va_list arglist);
  85. void LoadStringPrintf(UINT wIdString, CString * pString, ...);
  86. void SetWindowTextPrintf(HWND hwnd, UINT wIdString, ...);
  87. // If you are looking for MsgBoxPrintf() for slate, go
  88. // take a look at DoErrMsgBox()/DoServicesErrMsgBox() in svcutils.h
  89. // Function LoadStringWithInsertions() is exactly LoadStringPrintf()
  90. #define LoadStringWithInsertions LoadStringPrintf
  91. #ifdef SNAPIN_PROTOTYPER
  92. ///////////////////////////////////////
  93. struct TParseIntegerInfo // pi
  94. {
  95. int nFlags; // IN: Parsing flags
  96. const TCHAR * pchSrc; // IN: Source string
  97. const TCHAR * pchStop; // OUT: Pointer to where the parsing stopped
  98. int nErrCode; // OUT: Error code
  99. UINT uData; // OUT: Integer value
  100. UINT uRangeBegin; // IN: Lowest value for range checking
  101. UINT uRangeEnd; // IN: Highest value for range checking (inclusive)
  102. };
  103. #define PI_mskfDecimalBase 0x0000 // Use decimal base (default)
  104. #define PI_mskfHexBaseOnly 0x0001 // Use hexadecimal base only
  105. #define PI_mskfAllowHexBase 0x0002 // Look for a 0x prefix and select the appropriate base
  106. #define PI_mskfAllowRandomTail 0x0010 // Stop parsing as soon as you reach a non-digit character without returning an error
  107. #define PI_mskfNoEmptyString 0x0020 // Interpret an empty string as an error instead of the value zero
  108. #define PI_mskfNoMinusSign 0x0040 // Interpret the minus sign as an error
  109. #define PI_mskfSingleEntry 0x0080 // Return an error if there are more than one integer
  110. #define PI_mskfCheckRange 0x0100 // NYI: Use uRangeBegin and uRangeEnd to validate uData
  111. #define PI_mskfSilentParse 0x8000 // NYI: Used only when calling GetWindowInteger()
  112. #define PI_errOK 0 // No error
  113. #define PI_errIntegerOverflow 1 // Integer too large
  114. #define PI_errInvalidInteger 2 // String is not a valid integer (typically an invalid digit)
  115. #define PI_errEmptyString 3 // Empty string found while not allowed
  116. #define PI_errMinusSignFound 4 // The number was negative
  117. BOOL FParseInteger(INOUT TParseIntegerInfo * pPI);
  118. ///////////////////////////////////////
  119. typedef struct _SCANF_INFO // Scanf info structure (sfi)
  120. {
  121. const TCHAR * pchSrc; // IN: Source string to be parsed
  122. const TCHAR * pchSrcStop; // OUT: Pointer to where the parsing stopped
  123. int nErrCode; // OUT: Error code
  124. int cArgParsed; // OUT: Number of argument parsed
  125. } SCANF_INFO;
  126. #define SF_errInvalidFormat (-1) // Illegal format
  127. #define SF_errOK 0 // No error parsing
  128. #define SF_errTemplateMismatch 1 // Source string do not match with template string pchFmt
  129. ///////////////////////////////////////////////////////////
  130. BOOL FScanf(INOUT SCANF_INFO * pSFI, IN const TCHAR * pchFmt, OUT ...);
  131. BOOL RegKey_FQueryString(
  132. HKEY hKey,
  133. LPCTSTR pszValueName,
  134. CString& rstrKeyData);
  135. #endif // SNAPIN_PROTOTYPER
  136. class CStartStopHelper : public CComObjectRoot,
  137. public ISvcMgmtStartStopHelper,
  138. public CComCoClass<CStartStopHelper, &CLSID_SvcMgmt>
  139. {
  140. BEGIN_COM_MAP(CStartStopHelper)
  141. COM_INTERFACE_ENTRY(ISvcMgmtStartStopHelper)
  142. END_COM_MAP()
  143. public:
  144. // CStartStopHelper () {}
  145. // ~CStartStopHelper () {}
  146. DECLARE_AGGREGATABLE(CStartStopHelper)
  147. DECLARE_REGISTRY(CStartStopHelper, _T("SVCMGMT.StartStopObject.1"), _T("SVCMGMT.StartStopObject.1"), IDS_SVCVWR_DESC, THREADFLAGS_BOTH)
  148. STDMETHOD(StartServiceHelper)(
  149. HWND hwndParent,
  150. BSTR pszMachineName,
  151. BSTR pszServiceName,
  152. DWORD dwNumServiceArgs,
  153. BSTR * lpServiceArgVectors );
  154. STDMETHOD(ControlServiceHelper)(
  155. HWND hwndParent,
  156. BSTR pszMachineName,
  157. BSTR pszServiceName,
  158. DWORD dwControlCode );
  159. };
  160. DEFINE_GUID(IID_ISvcMgmtStartStopHelper,0xF62DEC25,0xE3CB,0x4D45,0x9E,0x98,0x93,0x3D,0xB9,0x5B,0xCA,0xEA);
  161. #endif // ~__UTILS_H__