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.

130 lines
1.9 KiB

  1. /*++
  2. Copyright (c) 1991 Microsoft Corporation
  3. Module Name:
  4. rtdelkey.c
  5. Abstract:
  6. NT level registry api test program, basic non-error paths.
  7. Delete a key.
  8. rtdelkey <KeyPath>
  9. Example:
  10. rtdelkey \REGISTRY\MACHINE\TEST\bigkey
  11. Author:
  12. Bryan Willman (bryanwi) 10-Jan-92
  13. Revision History:
  14. --*/
  15. #include "cmp.h"
  16. #include <stdio.h>
  17. #include <stdlib.h>
  18. #include <string.h>
  19. #define WORK_SIZE 1024
  20. void __cdecl main(int,char *);
  21. void processargs();
  22. void
  23. Delete(
  24. HANDLE Handle
  25. );
  26. UNICODE_STRING WorkName;
  27. WCHAR workbuffer[WORK_SIZE];
  28. void
  29. __cdecl main(
  30. int argc,
  31. char *argv[]
  32. )
  33. {
  34. NTSTATUS status;
  35. OBJECT_ATTRIBUTES ObjectAttributes;
  36. HANDLE BaseHandle;
  37. //
  38. // Process args
  39. //
  40. WorkName.MaximumLength = WORK_SIZE;
  41. WorkName.Length = 0L;
  42. WorkName.Buffer = &(workbuffer[0]);
  43. processargs(argc, argv);
  44. //
  45. // Set up and open KeyPath
  46. //
  47. printf("rtdelkey: starting\n");
  48. InitializeObjectAttributes(
  49. &ObjectAttributes,
  50. &WorkName,
  51. 0,
  52. (HANDLE)NULL,
  53. NULL
  54. );
  55. ObjectAttributes.Attributes |= OBJ_CASE_INSENSITIVE;
  56. status = NtOpenKey(
  57. &BaseHandle,
  58. DELETE,
  59. &ObjectAttributes
  60. );
  61. if (!NT_SUCCESS(status)) {
  62. printf("rtdelkey: t0: %08lx\n", status);
  63. exit(1);
  64. }
  65. status = NtDeleteKey(BaseHandle);
  66. if (!NT_SUCCESS(status)) {
  67. printf("rtdelkey: t1: %08lx\n", status);
  68. exit(1);
  69. }
  70. NtClose(BaseHandle);
  71. exit(0);
  72. }
  73. void
  74. processargs(
  75. int argc,
  76. char *argv[]
  77. )
  78. {
  79. ANSI_STRING temp;
  80. if ( (argc != 2) )
  81. {
  82. printf("Usage: %s <KeyPath>\n",
  83. argv[0]);
  84. exit(1);
  85. }
  86. RtlInitAnsiString(
  87. &temp,
  88. argv[1]
  89. );
  90. RtlAnsiStringToUnicodeString(
  91. &WorkName,
  92. &temp,
  93. TRUE
  94. );
  95. return;
  96. }