0

私の問題は、Registry.SetValue を使用しているときに、既存の値のみを更新したいということです。存在しない値名が入力された場合、作成したくありません。ユーザーが入力する変数データが​​あるため、コード内にパスをハードコードすることはできません。

私のセットの私のコード

    public class SetRegistryValue : CodeActivity
{
    [RequiredArgument]
    public InArgument<string> kpath { get; set; }

    public InArgument<string> txtName { get; set; }

    [RequiredArgument]
    public InArgument<string> kvaluename { get; set; }

    [RequiredArgument]
    public InArgument<string> kvalue { get; set; }

    //This will set the value of an key that is defined by user
    protected override void Execute(CodeActivityContext context)
    {

        string KeyPath = this.kpath.Get(context);
        string KeyValueName = this.kvaluename.Get(context);
        string KeyValue = this.kvalue.Get(context);
        string KeyName = Path.GetDirectoryName(KeyPath);
        string KeyFileName = Path.GetFileName(KeyPath);
        string fullKeyPath = KeyName + "\\" +  KeyFileName;

        Registry.SetValue(fullKeyPath, KeyValueName, KeyValue, RegistryValueKind.String);
    }
}
4

1 に答える 1