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.

157 lines
4.2 KiB

  1. /*++
  2. Copyright (c) 1992 Microsoft Corporation
  3. Module Name:
  4. wsregcfg.c
  5. Abstract:
  6. Registry access routines used by the Workstation (formerly in netlib.lib)
  7. Author:
  8. John Rogers (JohnRo) 08-May-1992
  9. Environment:
  10. Only requires ANSI C (slash-slash comments, long external names).
  11. Revision History:
  12. 08-May-1992 JohnRo
  13. Created.
  14. 01-Feb-2001 JSchwart
  15. Moved from netlib.lib to wkssvc.dll
  16. --*/
  17. #include <nt.h> // IN, etc. (Only needed by temporary config.h)
  18. #include <ntrtl.h> // (Only needed by temporary config.h)
  19. #include <nturtl.h> // (Only needed by temporary config.h)
  20. #include <windows.h> // IN, LPTSTR, etc.
  21. #include <lmcons.h> // NET_API_STATUS.
  22. #include <netdebug.h> // (Needed by config.h)
  23. #include <config.h> // My prototype, LPNET_CONFIG_HANDLE.
  24. #include <configp.h> // USE_WIN32_CONFIG (if defined), NET_CONFIG_HANDLE, etc
  25. #include <debuglib.h> // IF_DEBUG().
  26. #include <prefix.h> // PREFIX_ equates.
  27. #include <strarray.h> // LPTSTR_ARRAY.
  28. #include <tstr.h> // TCHAR_EOS.
  29. #include <winerror.h> // ERROR_NOT_SUPPORTED, NO_ERROR, etc.
  30. #include "wsregcfg.h" // Registry helpers
  31. NET_API_STATUS
  32. WsSetConfigTStrArray(
  33. IN LPNET_CONFIG_HANDLE ConfigHandle,
  34. IN LPTSTR Keyword,
  35. IN LPTSTR_ARRAY ArrayStart
  36. )
  37. {
  38. DWORD ArraySize; // byte count, incl both null chars at end.
  39. NET_CONFIG_HANDLE * MyHandle = ConfigHandle; // conv from opaque type
  40. if (MyHandle == NULL) {
  41. return (ERROR_INVALID_PARAMETER);
  42. } else if (Keyword == NULL) {
  43. return (ERROR_INVALID_PARAMETER);
  44. } else if (*Keyword == TCHAR_EOS) {
  45. return (ERROR_INVALID_PARAMETER);
  46. } else if (ArrayStart == NULL) {
  47. return (ERROR_INVALID_PARAMETER);
  48. }
  49. ArraySize = NetpTStrArraySize( ArrayStart );
  50. if (ArraySize == 0) {
  51. return (ERROR_INVALID_PARAMETER);
  52. }
  53. {
  54. LONG Error;
  55. Error = RegSetValueEx (
  56. MyHandle->WinRegKey, // open handle (to section)
  57. Keyword, // subkey
  58. 0,
  59. REG_MULTI_SZ, // type
  60. (LPVOID) ArrayStart, // data
  61. ArraySize ); // byte count for data
  62. IF_DEBUG(CONFIG) {
  63. NetpKdPrint(("[Wksta] WsSetConfigTStrArray: RegSetValueEx("
  64. FORMAT_LPTSTR ") returned " FORMAT_LONG ".\n",
  65. Keyword, Error ));
  66. }
  67. return ( (NET_API_STATUS) Error );
  68. }
  69. }
  70. NET_API_STATUS
  71. WsSetConfigBool (
  72. IN LPNET_CONFIG_HANDLE ConfigHandle,
  73. IN LPTSTR Keyword,
  74. IN BOOL Value
  75. )
  76. {
  77. //
  78. // Do boolean-specific error checking...
  79. //
  80. if ( (Value != TRUE) && (Value != FALSE) ) {
  81. return (ERROR_INVALID_PARAMETER);
  82. }
  83. //
  84. // Eventually, this might use some new data type. But for now, just
  85. // treat this as a DWORD request.
  86. //
  87. return (WsSetConfigDword(
  88. ConfigHandle,
  89. Keyword,
  90. (DWORD) Value) );
  91. }
  92. NET_API_STATUS
  93. WsSetConfigDword (
  94. IN LPNET_CONFIG_HANDLE ConfigHandle,
  95. IN LPTSTR Keyword,
  96. IN DWORD Value
  97. )
  98. {
  99. NET_CONFIG_HANDLE * MyHandle = ConfigHandle; // conv from opaque type
  100. {
  101. LONG Error;
  102. //
  103. // Set the actual value. We might have read this as REG_SZ or
  104. // REG_DWORD, but let's always write it as REG_DWORD. (This is
  105. // the WsSetConfigDword routine, after all.)
  106. //
  107. Error = RegSetValueEx (
  108. MyHandle->WinRegKey, // open handle (to section)
  109. Keyword, // subkey
  110. 0,
  111. REG_DWORD, // type
  112. (LPVOID) &Value, // data
  113. sizeof(DWORD) ); // byte count for data
  114. IF_DEBUG(CONFIG) {
  115. NetpKdPrint(("[Wksta] WsSetConfigDword: RegSetValueEx("
  116. FORMAT_LPTSTR ") returned " FORMAT_LONG ".\n",
  117. Keyword, Error ));
  118. }
  119. return ( (NET_API_STATUS) Error );
  120. }
  121. }