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

rtrenval.c

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

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