473,387 Members | 1,463 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Writng the Binary Data into Registry


Can any one put me a piece of code to write binary data into Registry?
Nov 15 '05 #1
8 10562
"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
Nov 15 '05 #2
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

Nov 15 '05 #3
Saradhi,

In this case, I would generate separate named values for each icon and
then use the logic to determine which key to access.

Also, have you considered using resources for storing this information?
It's a little more suited, IMO, for this kind of thing.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"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
Nov 15 '05 #4
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
Nov 15 '05 #5
On Fri, 05 Mar 2004 18:46:01 +0530, Saradhi wrote:
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?


This really constitutes abuse of the registry. Part of the reason Windows
is so flakey is because of morons using it as a database.

Nov 15 '05 #6
The .NET method of storing such data would be by using resources. Consider going thru those lines.

Regards,
fbhcah
Nov 15 '05 #7
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in
message news:uS**************@TK2MSFTNGP12.phx.gbl...
Also, have you considered using resources for storing this information?
It's a little more suited, IMO, for this kind of thing.


Can you suggest an on-line introduction to this?
Nov 15 '05 #8
Hi

If u had got any idea as how LoadBehaviour for add-in gets changed from 3 to 2 , pls do intimate me

Thx from advance

I require urgently

Th
Ajay
Nov 16 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Dmitry | last post by:
Hi! Does anybody know how to write binary data to registry? The purpose is to store an boxed object into registry and to restore it.
1
by: Niko Korhonen | last post by:
I'm currently in the process of programming a multimedia tagging library in standard C++. However, I've stumbled across one or two unclear issues while working with the library. First of all, is...
6
by: John Hoffman | last post by:
Reading registry: .... RegistryKey rksub = rkey.OpenSubKey(s); String valstr = rksub.GetValueNames(); foreach (String vs in valstr) { String vstr = rksub.GetValue(vs).ToString(); OR String...
0
by: Sharon McCarty | last post by:
Hi Everyone, I have a managed C++ web service and I'm trying to access the registry key that contains a binary data. Can someone tell me how to convert object __gc* to byte? I've got some...
4
by: Wolfgang Kaml | last post by:
I came accross the need to store binary data in the registry. The binary data to be saved is kept within a string in the code segment. If I write that string to a registry, not all of the data is...
6
by: | last post by:
Hi all, is there a better way to stream binary data stored in a table in sql 2005 to a browser in .net 2.0? Or is the code same as in .net 1.1? We noticed that in certain heavy load scenarios,...
0
by: Wescotte | last post by:
I'm abit confused on how to work with binary data with an ODBC connection (My database is DB2 btw) Say I have a table like CREATE TABLE EJWLIB.BLOBTEST ( ID NUMERIC(5) NOT NULL, FILENAME...
3
by: stockblaster | last post by:
Hello all.. Is it possible to convert a DataTable (i create the DataTable from a CSV file) into binary data and save it into an sql 2005 table (into binary field). After that I want to...
0
by: shankarkn | last post by:
I want to store a String value as a Binary data into the registry. The string value is a name & email address and it has to be stored in hex format. I am using the following CString l_strKey =...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.