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.

145 lines
3.8 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1997-2002.
  5. //
  6. // File: utils.h
  7. //
  8. // Contents:
  9. //
  10. //----------------------------------------------------------------------------
  11. #ifndef __UTILS_H
  12. #define __UTILS_H
  13. #include "cookie.h"
  14. typedef CArray<CCertTmplCookie*, CCertTmplCookie*> CCookiePtrArray;
  15. // Convert win32 error code to a text message and display
  16. void DisplaySystemError (HWND hParent, DWORD dwErr);
  17. void TraceSystemError (DWORD dwErr);
  18. extern PCWSTR MMC_APP;
  19. HRESULT FormatDate (FILETIME utcDateTime, CString & pszDateTime);
  20. bool IsWindowsNT ();
  21. LRESULT RegDelnode (HKEY hKeyRoot, CString pszSubKey);
  22. #define IID_PPV_ARG(Type, Expr) IID_##Type, \
  23. reinterpret_cast<void**>(static_cast<Type **>(Expr))
  24. #define g_cszHideWelcomePage L"Hide Session Wizard Welcome"
  25. enum {
  26. PUBLISHER_DIRECTORY = 1,
  27. SUBSCRIBER_DIRECTORY
  28. };
  29. HRESULT InitObjectPickerForDomainComputers(IDsObjectPicker *pDsObjectPicker);
  30. class CCertTmplComponentData; //forward declaration
  31. // {4E40F770-369C-11d0-8922-00A024AB2DBB}
  32. DEFINE_GUID(CLSID_DsSecurityPage, 0x4E40F770, 0x369C, 0x11d0, 0x89, 0x22, 0x0, 0xa0, 0x24, 0xab, 0x2d, 0xbb);
  33. #define MAX_ADS_ENUM 16
  34. void FreeStringArray (PWSTR* rgpszStrings, DWORD dwAddCount);
  35. typedef enum {
  36. CERTTMPL_OBJECT_CERT_TEMPLATE
  37. } CERTTMPL_OBJECT_TYPE;
  38. HRESULT DisplayObjectCountInStatusBar (LPCONSOLE pConsole, DWORD dwCnt);
  39. HRESULT DisplayRootNodeStatusBarText (LPCONSOLE pConsole);
  40. ////////////////////////////////////////////////////////////////////////////////
  41. // CCredentialObject
  42. class CCredentialObject
  43. {
  44. public :
  45. CCredentialObject() :
  46. m_pszPassword (0),
  47. m_bUseCredentials (false)
  48. {
  49. }
  50. CCredentialObject(CCredentialObject* pCredObject);
  51. ~CCredentialObject()
  52. {
  53. free(m_pszPassword);
  54. }
  55. CString GetUsername() const { return m_sUsername; }
  56. void SetUsername (PCWSTR pszUsername) { m_sUsername = pszUsername; }
  57. HRESULT GetPassword (PWSTR pszPassword, int bufLen) const;
  58. HRESULT SetPasswordFromHwnd (HWND hWnd);
  59. BOOL UseCredentials () const { return m_bUseCredentials; }
  60. void SetUseCredentials (const bool bUseCred) { m_bUseCredentials = bUseCred; }
  61. private :
  62. CString m_sUsername;
  63. PWSTR m_pszPassword;
  64. bool m_bUseCredentials;
  65. };
  66. // Do a case insensitive string compare that is safe for any locale.
  67. //
  68. // Arguments: [ptsz1] - strings to compare
  69. // [ptsz2]
  70. //
  71. // Returns: -1, 0, or 1 just like lstrcmpi
  72. int LocaleStrCmp (LPCWSTR ptsz1, LPCWSTR ptsz2);
  73. CString GetSystemMessage (DWORD dwErr);
  74. PCWSTR GetContextHelpFile ();
  75. ///////////////////////////////////////////////////////////////////////////////
  76. // OID functions
  77. ///////////////////////////////////////////////////////////////////////////////
  78. bool MyGetOIDInfoA (CString & string, LPCSTR pszObjId);
  79. HRESULT GetEnterpriseOIDs ();
  80. HRESULT GetBuiltInOIDS ();
  81. bool OIDHasValidFormat (PCWSTR pszOidValue, int& rErrorTypeStrID);
  82. ///////////////////////////////////////////////////////////////////////////////
  83. bool IsCerttypeEditingAllowed();
  84. void InstallWindows2002CertTemplates ();
  85. #ifdef UNICODE
  86. #define PROPSHEETPAGE_V3 PROPSHEETPAGEW_V3
  87. #else
  88. #define PROPSHEETPAGE_V3 PROPSHEETPAGEA_V3
  89. #endif
  90. HPROPSHEETPAGE MyCreatePropertySheetPage(AFX_OLDPROPSHEETPAGE* psp);
  91. class CThemeContextActivator
  92. {
  93. public:
  94. CThemeContextActivator() : m_ulActivationCookie(0)
  95. { SHActivateContext (&m_ulActivationCookie); }
  96. ~CThemeContextActivator()
  97. { SHDeactivateContext (m_ulActivationCookie); }
  98. private:
  99. ULONG_PTR m_ulActivationCookie;
  100. };
  101. #define MAX_TEMPLATE_NAME_LEN 256
  102. #endif