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.

210 lines
5.4 KiB

  1. // Copyright (c) 1997-2001 Microsoft Corporation
  2. //
  3. // File: common.h
  4. //
  5. // Synopsis: Defines some commonly used functions
  6. // This is really just a dumping ground for functions
  7. // that don't really belong to a specific class in
  8. // this design. They may be implemented in other
  9. // files besides common.cpp.
  10. //
  11. // History: 02/03/2001 JeffJon Created
  12. #define DNS_DOMAIN_NAME_MAX_LIMIT_DUE_TO_POLICY 64
  13. #define DNS_DOMAIN_NAME_MAX_LIMIT_DUE_TO_POLICY_UTF8 155
  14. #define MAX_NETBIOS_NAME_LENGTH DNLEN
  15. // Service names used for both the OCManager and launching wizards
  16. #define CYS_DHCP_SERVICE_NAME L"DHCPServer"
  17. #define CYS_DNS_SERVICE_NAME L"DNS"
  18. #define CYS_PRINTER_WIZARD_NAME L"AddPrinter"
  19. #define CYS_PRINTER_DRIVER_WIZARD_NAME L"AddPrinterDriver"
  20. #define CYS_RRAS_SERVICE_NAME L"RRAS"
  21. #define CYS_WEB_SERVICE_NAME L"IISAdmin"
  22. #define CYS_WINS_SERVICE_NAME L"WINS"
  23. // Other needed constants
  24. // Switch provided by explorer.exe when launching CYS
  25. #define EXPLORER_SWITCH L"explorer"
  26. extern Popup popup;
  27. // Sets the font of a given control in a dialog.
  28. //
  29. // parentDialog - Dialog containing the control.
  30. //
  31. // controlID - Res ID of the control for which the font will be
  32. // changed.
  33. //
  34. // font - handle to the new font for the control.
  35. void
  36. SetControlFont(HWND parentDialog, int controlID, HFONT font);
  37. // Sets the font of a control to a large point bold font as per Wizard '97
  38. // spec.
  39. //
  40. // dialog - handle to the dialog that is the parent of the control
  41. //
  42. // bigBoldResID - resource id of the control to change
  43. void
  44. SetLargeFont(HWND dialog, int bigBoldResID);
  45. bool
  46. IsServiceInstalledHelper(const wchar_t* serviceName);
  47. bool
  48. InstallServiceWithOcManager(
  49. const String& infText,
  50. const String& unattendText);
  51. DWORD
  52. MyWaitForSendMessageThread(HANDLE hThread, DWORD dwTimeout);
  53. HRESULT
  54. CreateTempFile(const String& name, const String& contents);
  55. HRESULT
  56. CreateAndWaitForProcess(const String& commandLine, DWORD& exitCode);
  57. HRESULT
  58. MyCreateProcess(const String& commandLine);
  59. bool
  60. IsKeyValuePresent(RegistryKey& key, const String& value);
  61. bool
  62. GetRegKeyValue(
  63. const String& key,
  64. const String& value,
  65. String& resultString,
  66. HKEY parentKey = HKEY_LOCAL_MACHINE);
  67. bool
  68. GetRegKeyValue(
  69. const String& key,
  70. const String& value,
  71. DWORD& resultValue,
  72. HKEY parentKey = HKEY_LOCAL_MACHINE);
  73. bool
  74. SetRegKeyValue(
  75. const String& key,
  76. const String& value,
  77. const String& newString,
  78. HKEY parentKey = HKEY_LOCAL_MACHINE,
  79. bool create = false);
  80. bool
  81. SetRegKeyValue(
  82. const String& key,
  83. const String& value,
  84. DWORD newValue,
  85. HKEY parentKey = HKEY_LOCAL_MACHINE,
  86. bool create = false);
  87. bool
  88. ExecuteWizard(PCWSTR serviceName, String& resultText);
  89. // This really comes from Burnslib but it is not provided in a header
  90. // so I am putting the declaration here and we will link to the
  91. // Burnslib definition
  92. HANDLE
  93. AppendLogFile(const String& logBaseName, String& logName);
  94. // Macros to help with the log file operations
  95. #define CYS_APPEND_LOG(text) \
  96. if (logfileHandle) \
  97. FS::Write(logfileHandle, text);
  98. bool
  99. IsDhcpConfigured();
  100. extern "C"
  101. {
  102. BOOL
  103. IsDHCPAvailableOnInterface(DWORD ipaddress);
  104. }
  105. bool
  106. IsIndexingServiceOn();
  107. HRESULT
  108. StartIndexingService();
  109. HRESULT
  110. StopIndexingService();
  111. // Validates a dns domain name for proper syntax and length. If validation
  112. // fails, presents appropriate error messages to the user, and sets the input
  113. // focus to a given control. Syntactically valid but non-RFC compliant dns
  114. // names cause a warning message to be presented (but validation does not
  115. // fail). Returns true if the validation succeed, false if not.
  116. //
  117. // dialog - handle to the dialog containing the edit box that: contains the
  118. // name to be validated and receives focus if the validation fails.
  119. //
  120. // domainName - the domain name to validate. If the empty string, then the
  121. // name is taken from the edit control identified by editResID.
  122. //
  123. // editResID - the resource id of the edit control containing the domain name
  124. // to be validated (if the domainName parameter is empty), also receives input
  125. // focus if validation fails.
  126. //
  127. // warnOnNonRFC - issue a non-fatal warning if the name is not RFC compliant.
  128. //
  129. // isNonRFC - optional pointer to bool to be set to true if the name is
  130. // not a RFC-compliant name.
  131. bool
  132. ValidateDomainDnsNameSyntax(
  133. HWND dialog,
  134. const String& domainName,
  135. int editResID,
  136. bool warnOnNonRFC,
  137. bool* isNonRFC = 0);
  138. // Overloads ValidateDomainDnsNameSyntax such that the domain name to be
  139. // validated is taken from the edit control specified by editResID.
  140. bool
  141. ValidateDomainDnsNameSyntax(
  142. HWND dialog,
  143. int editResID,
  144. bool warnOnNonRFC,
  145. bool* isNonRFC = 0);
  146. // If the new domain name is a single DNS label, then ask the user to confirm
  147. // that name. If the user rejects the name, set focus to the domain name edit
  148. // box, return false. Otherwise, return true.
  149. //
  150. // parentDialog - HWND of the dialog with the edit box control.
  151. //
  152. // editResID - resource ID of the domain name edit box containing the name to
  153. // be confirmed.
  154. //
  155. // 309670
  156. bool
  157. ConfirmNetbiosLookingNameIsReallyDnsName(HWND parentDialog, int editResID);
  158. // Converts a VARIANT of type VT_ARRAY | VT_BSTR to a list of Strings
  159. HRESULT
  160. VariantArrayToStringList(VARIANT* variant, StringList& stringList);