Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

rtdelkey.c

Go to the documentation of this file.
00001 /*++ 00002 00003 Copyright (c) 1991 Microsoft Corporation 00004 00005 Module Name: 00006 00007 rtdelkey.c 00008 00009 Abstract: 00010 00011 NT level registry api test program, basic non-error paths. 00012 00013 Delete a key. 00014 00015 rtdelkey <KeyPath> 00016 00017 Example: 00018 00019 rtdelkey \REGISTRY\MACHINE\TEST\bigkey 00020 00021 Author: 00022 00023 Bryan Willman (bryanwi) 10-Jan-92 00024 00025 Revision History: 00026 00027 --*/ 00028 00029 #include "cmp.h" 00030 #include <stdio.h> 00031 #include <stdlib.h> 00032 #include <string.h> 00033 00034 #define WORK_SIZE 1024 00035 00036 void __cdecl main(int,char *); 00037 void processargs(); 00038 00039 void 00040 Delete( 00041 HANDLE Handle 00042 ); 00043 00044 UNICODE_STRING WorkName; 00045 WCHAR workbuffer[WORK_SIZE]; 00046 00047 void 00048 __cdecl main( 00049 int argc, 00050 char *argv[] 00051 ) 00052 { 00053 NTSTATUS status; 00054 OBJECT_ATTRIBUTES ObjectAttributes; 00055 HANDLE BaseHandle; 00056 00057 // 00058 // Process args 00059 // 00060 00061 WorkName.MaximumLength = WORK_SIZE; 00062 WorkName.Length = 0L; 00063 WorkName.Buffer = &(workbuffer[0]); 00064 00065 processargs(argc, argv); 00066 00067 00068 // 00069 // Set up and open KeyPath 00070 // 00071 00072 printf("rtdelkey: starting\n"); 00073 00074 InitializeObjectAttributes( 00075 &ObjectAttributes, 00076 &WorkName, 00077 0, 00078 (HANDLE)NULL, 00079 NULL 00080 ); 00081 ObjectAttributes.Attributes |= OBJ_CASE_INSENSITIVE; 00082 00083 status = NtOpenKey( 00084 &BaseHandle, 00085 DELETE, 00086 &ObjectAttributes 00087 ); 00088 if (!NT_SUCCESS(status)) { 00089 printf("rtdelkey: t0: %08lx\n", status); 00090 exit(1); 00091 } 00092 00093 status = NtDeleteKey(BaseHandle); 00094 if (!NT_SUCCESS(status)) { 00095 printf("rtdelkey: t1: %08lx\n", status); 00096 exit(1); 00097 } 00098 00099 NtClose(BaseHandle); 00100 exit(0); 00101 } 00102 00103 void 00104 processargs( 00105 int argc, 00106 char *argv[] 00107 ) 00108 { 00109 ANSI_STRING temp; 00110 00111 if ( (argc != 2) ) 00112 { 00113 printf("Usage: %s <KeyPath>\n", 00114 argv[0]); 00115 exit(1); 00116 } 00117 00118 RtlInitAnsiString( 00119 &temp, 00120 argv[1] 00121 ); 00122 00123 RtlAnsiStringToUnicodeString( 00124 &WorkName, 00125 &temp, 00126 TRUE 00127 ); 00128 00129 return; 00130 }

Generated on Sat May 15 19:41:40 2004 for test by doxygen 1.3.7