Source code of Windows XP (NT5)
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.

125 lines
3.8 KiB

  1. #ifndef MISC_H
  2. #define MISC_H
  3. #ifndef MAX
  4. #define MAX(x,y) (((x) > (y)) ? (x) : (y))
  5. #endif
  6. #ifndef MIN
  7. #define MIN(x,y) (((x) < (y)) ? (x) : (y))
  8. #endif
  9. #define GetDlgItemTextLength(hwnd, id) \
  10. GetWindowTextLength(GetDlgItem(hwnd, id))
  11. #define WIZARDNEXT(hwnd, to) \
  12. SetWindowLongPtr(hwnd, DWLP_MSGRESULT, (LPARAM)to)
  13. // wait cursor management
  14. class CWaitCursor
  15. {
  16. public:
  17. CWaitCursor();
  18. ~CWaitCursor();
  19. void WaitCursor();
  20. void RestoreCursor();
  21. private:
  22. HCURSOR _hCursor;
  23. };
  24. HRESULT BrowseToPidl(LPCITEMIDLIST pidl);
  25. void FetchText(HWND hWndDlg, UINT uID, LPTSTR lpBuffer, DWORD dwMaxSize);
  26. INT FetchTextLength(HWND hWndDlg, UINT uID);
  27. HRESULT AttemptLookupAccountName(LPCTSTR szUsername, PSID* ppsid,
  28. LPTSTR szDomain, DWORD* pcchDomain,
  29. SID_NAME_USE* psUse);
  30. int DisplayFormatMessage(HWND hwnd, UINT idCaption, UINT idFormatString, UINT uType, ...);
  31. BOOL FormatMessageString(UINT idTemplate, LPTSTR pszStrOut, DWORD cchSize, ...);
  32. BOOL FormatMessageTemplate(LPCTSTR pszTemplate, LPTSTR pszStrOut, DWORD cchSize, ...);
  33. void MakeDomainUserString(LPCTSTR szDomain, LPCTSTR szUsername, LPTSTR szDomainUser, DWORD cchBuffer);
  34. void DomainUserString_GetParts(LPCTSTR szDomainUser, LPTSTR szUser, DWORD cchUser, LPTSTR szDomain, DWORD cchDomain);
  35. BOOL GetCurrentUserAndDomainName(LPTSTR UserName, LPDWORD cchUserName, LPTSTR DomainName, LPDWORD cchDomainName);
  36. HRESULT IsUserLocalAdmin(HANDLE TokenHandle OPTIONAL, BOOL* pfIsAdmin);
  37. BOOL IsComputerInDomain();
  38. LPITEMIDLIST GetComputerParent();
  39. void EnableControls(HWND hwnd, const UINT* prgIDs, DWORD cIDs, BOOL fEnable);
  40. void OffsetControls(HWND hwnd, const UINT* prgIDs, DWORD cIDs, int dx, int dy);
  41. void OffsetWindow(HWND hwnd, int dx, int dy);
  42. HFONT GetIntroFont(HWND hwnd);
  43. void CleanUpIntroFont();
  44. void RemoveControl(HWND hwnd, UINT idControl, UINT idNextControl, const UINT* prgMoveControls, DWORD cControls, BOOL fShrinkParent);
  45. void MoveControls(HWND hwnd, const UINT* prgControls, DWORD cControls, int dx, int dy);
  46. int SizeControlFromText(HWND hwnd, UINT id, LPTSTR psz);
  47. void EnableDomainForUPN(HWND hwndUsername, HWND hwndDomain);
  48. int PropertySheetIcon(LPCPROPSHEETHEADER ppsh, LPCTSTR pszIcon);
  49. // Stuff for the callback for IShellPropSheetExt::AddPages
  50. #define MAX_PROPSHEET_PAGES 10
  51. struct ADDPROPSHEETDATA
  52. {
  53. HPROPSHEETPAGE rgPages[MAX_PROPSHEET_PAGES];
  54. int nPages;
  55. };
  56. BOOL AddPropSheetPageCallback(HPROPSHEETPAGE hpsp, LPARAM lParam);
  57. // single instance management
  58. class CEnsureSingleInstance
  59. {
  60. public:
  61. CEnsureSingleInstance(LPCTSTR szCaption);
  62. ~CEnsureSingleInstance();
  63. BOOL ShouldExit() { return m_fShouldExit;}
  64. private:
  65. BOOL m_fShouldExit;
  66. HANDLE m_hEvent;
  67. };
  68. // BrowseForUser
  69. // S_OK = Username/Domain are Ok
  70. // S_FALSE = User clicked cancel
  71. // E_xxx = Error
  72. HRESULT BrowseForUser(HWND hwndDlg, TCHAR* pszUser, DWORD cchUser, TCHAR* pszDomain, DWORD cchDomain);
  73. int CALLBACK ShareBrowseCallback(HWND hwnd, UINT uMsg, LPARAM lParam, LPARAM lpData);
  74. // Passport functions - implemented in PassportMisc.cpp
  75. #define PASSPORTURL_REGISTRATION L"RegistrationUrl"
  76. #define PASSPORTURL_LOGON L"LoginServerUrl"
  77. #define PASSPORTURL_PRIVACY L"Privacy"
  78. HRESULT PassportGetURL(PCWSTR pszName, PWSTR pszBuf, PDWORD pdwBufLen);
  79. VOID PassportForceNexusRepopulate();
  80. // Launch ICW if it hasn't been run yet
  81. void LaunchICW();
  82. // LookupLocalGroupName - retrieves a local group name for a given RID.
  83. // RID is one of these:
  84. // DOMAIN_ALIAS_RID_ADMINS
  85. // DOMAIN_ALIAS_RID_USERS
  86. // DOMAIN_ALIAS_RID_GUESTS
  87. // DOMAIN_ALIAS_RID_POWER_USERS
  88. // etc... (look in the SDK for other groups)
  89. HRESULT LookupLocalGroupName(DWORD dwRID, LPWSTR pszName, DWORD cchName);
  90. #endif //!MISC_H