Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 1.0 > C#
|
C# Programming questions specific to the Microsoft C# language. See also the forum Beginning Visual C# to discuss that specific Wrox book and code.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 12th, 2006, 02:23 AM
Authorized User
 
Join Date: May 2004
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to sencee Send a message via AIM to sencee Send a message via MSN to sencee Send a message via Yahoo to sencee
Default Working with HEX'ed Binary Registry Strings

Simple deffinition of a simple problem that is bugging me and cant get the exact output I desire.

I am retrieving a long binary value from the registry which comes through like this

01 00 00 0a 00 12 00 00
2c 11 08 00 00 00 00 01
b0 04 00 00 00 01 01 00
01 01 00 12 34 00 00 02

When i get this value and hold it in an object (of base type OBJECT} it converts to a byte array with 32 elements. Each elements represents each of the 2byte Hex tickets.

I am interested in is the values of 0x[16] and 0x[17] (represented here by B0 and 04.
this is stored in my byte array as
MyByteArray[15] is held as int 176
MyByteArray[16] is held as int 4

I have an integer value somewhere else, lets say 400.
If I convert this to a string and format it as hex i get 0190

I now need to split the hex string into Hex1 (holding 01) and Hex2 (holding 90)
Convert these back into from single 16b Hex vals into ints
MyByteArray[15] = intHex1 = 1
MyByteArray[16] = intHex2 = 144

----------------------------------
Been messing with this for a while now, and the problem that I am having is that I cant get my new ints into the byte array, becasue i get the message

object cannot be accessed with []

and I can not cast it on it's inception,cause int, char and string arrays aren't valids casts for the action and obviously singles wont hold it, so it just comes in as a registrey value always held in object.


Anyone help me with some code for this?

Regards
NJC
(an inadequate programmer)
 
Old April 12th, 2006, 08:07 AM
Authorized User
 
Join Date: May 2004
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to sencee Send a message via AIM to sencee Send a message via MSN to sencee Send a message via Yahoo to sencee
Default

SOLVED

NJC
(An Inadequate, but somewhat now more confident programmer)

 
Old April 13th, 2006, 03:59 AM
Registered User
 
Join Date: Apr 2006
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

How did you solved this?
Did you went for an byte array?






Similar Threads
Thread Thread Starter Forum Replies Last Post
Working With Binary ~Bean~ .NET Framework 1.x 2 February 3rd, 2006 04:59 PM
Registry Akmal Shah BOOK: Access 2003 VBA Programmer's Reference 1 May 25th, 2005 06:30 PM
Working with Win 32 Registry pannet1 BOOK: Access 2003 VBA Programmer's Reference 4 April 27th, 2005 03:45 AM
Registry snowy0 VB.NET 2002/2003 Basics 1 September 8th, 2004 10:40 AM
Registry jake Pro VB.NET 2002/2003 5 November 6th, 2003 04:02 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.