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

rtdelval.c

Go to the documentation of this file.
00001 /*++ 00002 00003 Copyright (c) 1991 Microsoft Corporation 00004 00005 Module Name: 00006 00007 rtdelval.c 00008 00009 Abstract: 00010 00011 NT level registry api test program, basic non-error paths. 00012 00013 Delete a key's value entry (field) 00014 00015 rtdelval <KeyPath> <value entry name> 00016 00017 Example: 00018 00019 rtdelval \REGISTRY\MACHINE\TEST\bigkey first_value_field 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 UNICODE_STRING ValueName; 00048 WCHAR valuebuffer[WORK_SIZE]; 00049 00050 void 00051 __cdecl main( 00052 int argc, 00053 char *argv[] 00054 ) 00055 { 00056 NTSTATUS status; 00057 OBJECT_ATTRIBUTES ObjectAttributes; 00058 HANDLE BaseHandle; 00059 00060 // 00061 // Process args 00062 // 00063 00064 WorkName.MaximumLength = WORK_SIZE; 00065 WorkName.Length = 0L; 00066 WorkName.Buffer = &(workbuffer[0]); 00067 00068 00069 ValueName.MaximumLength = WORK_SIZE; 00070 ValueName.Length = 0L; 00071 ValueName.Buffer = &(valuebuffer[0]); 00072 00073 processargs(argc, argv); 00074 00075 00076 // 00077 // Set up and open KeyPath 00078 // 00079 00080 printf("rtdelval: starting\n"); 00081 00082 InitializeObjectAttributes( 00083 &ObjectAttributes, 00084 &WorkName, 00085 0, 00086 (HANDLE)NULL, 00087 NULL 00088 ); 00089 ObjectAttributes.Attributes |= OBJ_CASE_INSENSITIVE; 00090 00091 status = NtOpenKey( 00092 &BaseHandle, 00093 KEY_SET_VALUE, 00094 &ObjectAttributes 00095 ); 00096 if (!NT_SUCCESS(status)) { 00097 printf("rtdelval: t0: %08lx\n", status); 00098 exit(1); 00099 } 00100 00101 status = NtDeleteValueKey(BaseHandle, &ValueName); 00102 if (!NT_SUCCESS(status)) { 00103 printf("rtdelval: t1: %08lx\n", status); 00104 exit(1); 00105 } 00106 00107 NtClose(BaseHandle); 00108 exit(0); 00109 } 00110 00111 void 00112 processargs( 00113 int argc, 00114 char *argv[] 00115 ) 00116 { 00117 ANSI_STRING temp; 00118 00119 if ( (argc != 3) ) 00120 { 00121 printf("Usage: %s <KeyPath> <value entry name>\n", 00122 argv[0]); 00123 exit(1); 00124 } 00125 00126 RtlInitAnsiString( 00127 &temp, 00128 argv[1] 00129 ); 00130 00131 RtlAnsiStringToUnicodeString( 00132 &WorkName, 00133 &temp, 00134 TRUE 00135 ); 00136 00137 RtlInitAnsiString( 00138 &temp, 00139 argv[2] 00140 ); 00141 00142 RtlAnsiStringToUnicodeString( 00143 &ValueName, 00144 &temp, 00145 TRUE 00146 ); 00147 00148 return; 00149 }

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