I wouldn't use the Registry for this, at least, not to store the actual
icon. Instead, I would keep the various icons in a subfolder somewhere on
the machine in question - if your code can read the Registry, it can also
read the file system - and then determine which one to use as required.
The Registry is designed for (and best suited to) storing lots of little
bits of information, not as a substitute for the file system
"Saradhi" <up*******@inooga.com> wrote in message
news:ea**************@TK2MSFTNGP09.phx.gbl...
This make sense. But I would like to put an image data into the registry.
For example, I have a Add-In and I have it's AboutBoxIcon and I am trying to
change the Icon depending on some logic.
Wt could be the best way to do it?
"Mark Rae" <ma**@markrae.co.uk> wrote in message
news:ux**************@TK2MSFTNGP09.phx.gbl...
"Saradhi" <up*******@inooga.com> wrote in message
news:eE****************@TK2MSFTNGP11.phx.gbl...
Can any one put me a piece of code to write binary data into Registry?
I don't have a piece of C# code at hand as I'm not at home, but I believe
the technique is fairly simple:
1) Reference the Registry object in the Microsoft.Win32 namespace
2) Create the subkey (if it doesn't already exist) where the binary value
will reside
3) Convert the value to be stored into a byte array
4) Call the SetValue method of the Registry object
The following is a VB.NET example which you should be able to modify easily
for C#:
Dim rk As Microsoft.Win32.RegistryKey
rk = Microsoft.Win32.Registry.CurrentUser.CreateSubKey( "Software\Test")
Dim b() As Byte = {1, 2, 3, 4, 5, 6}
rk.SetValue("A Value", b)
HTH.
Mark