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.

94 lines
2.4 KiB

  1. /*++
  2. Copyright (c) 1992 Microsoft Corporation
  3. Module Name:
  4. ConfDel.c
  5. Abstract:
  6. This module contains NetpDeleteConfigKeyword().
  7. Author:
  8. John Rogers (JohnRo) 11-Feb-1992
  9. Environment:
  10. Portable to any flat, 32-bit environment. (Uses Win32 typedefs.)
  11. Requires ANSI C extensions: slash-slash comments, long external names.
  12. Revision History:
  13. 11-Feb-1992 JohnRo
  14. Created this routine.
  15. 14-Mar-1992 JohnRo
  16. The Win32 registry version should call RegDeleteValue(), not
  17. RegDeleteKey().
  18. 22-Mar-1992 JohnRo
  19. Match revised return code (ERROR_CANTOPEN) from RegDeleteKey().
  20. Added a little debug output if the delete fails (WinReg version).
  21. 21-May-1992 JohnRo
  22. RAID 9826: Match revised winreg error codes.
  23. Use PREFIX_ equates.
  24. --*/
  25. // These must be included first:
  26. #include <nt.h> // NT definitions
  27. #include <ntrtl.h> // NT Rtl structures
  28. #include <nturtl.h> // NT Rtl structures
  29. #include <windows.h> // Needed by <configp.h> and <winreg.h>
  30. #include <lmcons.h> // NET_API_STATUS.
  31. #include <netdebug.h> // (Needed by config.h)
  32. // These may be included in any order:
  33. #include <config.h> // My prototype, LPNET_CONFIG_HANDLE.
  34. #include <configp.h> // NET_CONFIG_HANDLE.
  35. #include <lmerr.h> // NERR_, ERROR_, and NO_ERROR equates.
  36. #include <prefix.h> // PREFIX_ equates.
  37. #include <tstr.h> // TCHAR_EOS.
  38. #include <winreg.h>
  39. // Delete a keyword and its value.
  40. // Return NERR_CfgParamNotFound if the keyword isn't present.
  41. NET_API_STATUS
  42. NetpDeleteConfigKeyword (
  43. IN LPNET_CONFIG_HANDLE ConfigHandle,
  44. IN LPTSTR Keyword
  45. )
  46. {
  47. NET_CONFIG_HANDLE * MyHandle = (LPVOID) ConfigHandle;
  48. if (MyHandle == NULL) {
  49. return (ERROR_INVALID_PARAMETER);
  50. }
  51. if ( (Keyword == NULL) || (*Keyword == TCHAR_EOS) ) {
  52. return (ERROR_INVALID_PARAMETER);
  53. }
  54. {
  55. LONG Error;
  56. Error = RegDeleteValue (
  57. MyHandle->WinRegKey, // section (key) handle
  58. Keyword ); // value name
  59. if (Error == ERROR_FILE_NOT_FOUND) {
  60. return (NERR_CfgParamNotFound);
  61. }
  62. if (Error != ERROR_SUCCESS) {
  63. NetpKdPrint(( PREFIX_NETLIB
  64. "NetpConfigDeleteKeyword: unexpected status "
  65. FORMAT_LONG ".\n", Error ));
  66. NetpAssert( Error == ERROR_SUCCESS );
  67. }
  68. return Error;
  69. }
  70. }