Reputation: 143
The goal of my situation/problem is I want to setValue of my getValue to a destination within the registry. I am not not too familiar with get/sets, so any help would be awesome. Let me know if you need anything else from me.
namespace RegistrySetter
{
public class Ironman : CodeActivity
{
public InArgument<string> keypath { get; set; }
public OutArgument<string> TextOut { get; set; }
protected override void Execute(CodeActivityContext context)
{
string KeyPath = this.keypath.Get(context);
context.SetValue<string>(this.TextOut, KeyPath);
}
}
}
Upvotes: 0
Views: 124
Reputation: 40818
To get a registry value, you would probably use Registry.GetValue
. The you just have to use the context to set the output argument.
An example:
using System;
using System.Activities;
using Microsoft.Win32;
using System.IO;
public class GetRegistryValue : CodeActivity
{
[RequiredArgument]
public InArgument<string> KeyPath { get; set; }
public OutArgument<string> TextOut { get; set; }
protected override void Execute(CodeActivityContext context)
{
string keyPath = this.KeyPath.Get(context);
string keyName = Path.GetDirectoryName(keyPath);
string valueName = Path.GetFileName(keyPath);
object value = Registry.GetValue(keyName, valueName, "");
context.SetValue(this.TextOut, value.ToString());
}
}
Here KeyPath is something like: HKEY_CURRENT_USER\Software\7-Zip\Path
where Path
is actually the value name and HKEY_CURRENT_USER\Software\7-Zip
is the key name.
If you want to set a registry value look into Registry.SetValue
.
Upvotes: 1