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

◆ SetEnvironmentVariableFromRegistry()

static unsafe void System.Environment.SetEnvironmentVariableFromRegistry ( string variable,
string value,
bool fromMachine )
inlinestaticprivate

Definition at line 568 of file Environment.cs.

569 {
570 if (!fromMachine && variable.Length >= 255)
571 {
572 throw new ArgumentException(SR.Argument_LongEnvVarValue, "variable");
573 }
574 using (RegistryKey registryKey = OpenEnvironmentKeyIfExists(fromMachine, writable: true))
575 {
576 if (registryKey != null)
577 {
578 if (value == null)
579 {
580 registryKey.DeleteValue(variable, throwOnMissingValue: false);
581 }
582 else
583 {
584 registryKey.SetValue(variable, value);
585 }
586 }
587 }
588 fixed (char* ptr = &"Environment".GetPinnableReference())
589 {
590 IntPtr pdwResult;
591 IntPtr intPtr = Interop.User32.SendMessageTimeout(new IntPtr(65535), 26, IntPtr.Zero, (IntPtr)ptr, 0, 1000, out pdwResult);
592 }
593 }
void DeleteValue(string name, bool throwOnMissingValue)
void SetValue(string name, string value)
static IntPtr SendMessageTimeout(IntPtr hWnd, int msg, IntPtr wParam, IntPtr lParam, int flags, int timeout, out IntPtr pdwResult)
static RegistryKey OpenEnvironmentKeyIfExists(bool fromMachine, bool writable)

References System.SR.Argument_LongEnvVarValue, Internal.Win32.RegistryKey.DeleteValue(), System.Environment.OpenEnvironmentKeyIfExists(), Interop.User32.SendMessageTimeout(), Internal.Win32.RegistryKey.SetValue(), System.value, and System.IntPtr.Zero.

Referenced by System.Environment.SetEnvironmentVariable().