Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ GetValue() [2/2]

object Internal.Win32.RegistryKey.GetValue ( string name,
object defaultValue )
inline

Definition at line 141 of file RegistryKey.cs.

142 {
143 object result = defaultValue;
144 int lpType = 0;
145 int lpcbData = 0;
146 int num = Interop.Advapi32.RegQueryValueEx(_hkey, name, (int[])null, ref lpType, (byte[])null, ref lpcbData);
147 if (num != 0 && num != 234)
148 {
149 return result;
150 }
151 if (lpcbData < 0)
152 {
153 lpcbData = 0;
154 }
155 switch (lpType)
156 {
157 case 0:
158 case 3:
159 case 5:
160 {
161 byte[] array3 = new byte[lpcbData];
163 result = array3;
164 break;
165 }
166 case 11:
167 if (lpcbData <= 8)
168 {
169 long lpData = 0L;
171 result = lpData;
172 break;
173 }
174 goto case 0;
175 case 4:
176 if (lpcbData <= 4)
177 {
178 int lpData2 = 0;
180 result = lpData2;
181 break;
182 }
183 goto case 11;
184 case 1:
185 {
186 if (lpcbData % 2 == 1)
187 {
188 try
189 {
191 }
193 {
195 }
196 }
197 char[] array4 = new char[lpcbData / 2];
199 result = ((array4.Length == 0 || array4[^1] != 0) ? new string(array4) : new string(array4, 0, array4.Length - 1));
200 break;
201 }
202 case 2:
203 {
204 if (lpcbData % 2 == 1)
205 {
206 try
207 {
209 }
211 {
213 }
214 }
215 char[] array5 = new char[lpcbData / 2];
217 result = ((array5.Length == 0 || array5[^1] != 0) ? new string(array5) : new string(array5, 0, array5.Length - 1));
218 result = Environment.ExpandEnvironmentVariables((string)result);
219 break;
220 }
221 case 7:
222 {
223 if (lpcbData % 2 == 1)
224 {
225 try
226 {
228 }
230 {
232 }
233 }
234 char[] array = new char[lpcbData / 2];
236 if (array.Length != 0 && array[^1] != 0)
237 {
238 Array.Resize(ref array, array.Length + 1);
239 }
240 string[] array2 = Array.Empty<string>();
241 int num2 = 0;
242 int num3 = 0;
243 int num4 = array.Length;
244 while (num == 0 && num3 < num4)
245 {
246 int i;
247 for (i = num3; i < num4 && array[i] != 0; i++)
248 {
249 }
250 string text = null;
251 if (i < num4)
252 {
253 if (i - num3 > 0)
254 {
255 text = new string(array, num3, i - num3);
256 }
257 else if (i != num4 - 1)
258 {
259 text = string.Empty;
260 }
261 }
262 else
263 {
264 text = new string(array, num3, num4 - num3);
265 }
266 num3 = i + 1;
267 if (text != null)
268 {
269 if (array2.Length == num2)
270 {
271 Array.Resize(ref array2, (num2 > 0) ? (num2 * 2) : 4);
272 }
273 array2[num2++] = text;
274 }
275 }
276 Array.Resize(ref array2, num2);
277 result = array2;
278 break;
279 }
280 }
281 return result;
282 }
readonly SafeRegistryHandle _hkey
static int RegQueryValueEx(SafeRegistryHandle hKey, string lpValueName, int[] lpReserved, ref int lpType, [Out] byte[] lpData, ref int lpcbData)
static string ExpandEnvironmentVariables(string name)
static string Arg_RegGetOverflowBug
Definition SR.cs:386
Definition SR.cs:7

References Internal.Win32.RegistryKey._hkey, System.SR.Arg_RegGetOverflowBug, System.array, System.Environment.ExpandEnvironmentVariables(), System.L, Interop.Advapi32.RegQueryValueEx(), and System.text.