Saving to the register in .net

  • Hello,


    I am using the following code in C# to write and save to the register


    Code
    1. RegistryKey Reg = Registry.LocalMachine.CreateSubKey("Some\\Thing");
    2. Reg.SetValue("SomeValue", (string)string.Empty);
    3. Reg.Close();


    Then it is saved to the register, however when I unplug the netdcu from the power, and reboot it again, the keys are saved in the register, but the values are not present.


    Thanks in advance,


    Kelkafa

  • Hello,
    i did not test it but i think the behavior is similar as in EVC++. There you have to call ::Flush() (RegFlushKey()) before close an open key for save modifications.

    F&S Elektronik Systeme GmbH
    As this is an international forum, please try to post in English.
    Da dies ein internationales Forum ist, bitten wir darum, Beiträge möglichst in Englisch zu verfassen.

  • Hi,


    i tried it with VB.net, but it don´t work. Any idea for a solution?


    Code
    1. Dim RegKey As RegistryKey
    2. RegKey = Registry.LocalMachine.OpenSubKey("init", True)
    3. RegKey.DeleteValue("Launch50")
    4. RegKey.Flush()
    5. RegKey.Close()


    best regards Benjamin

  • Hi,


    with a Workaround over the API it work´s. Thx to F&S, for the support.



    best regards Benjamin