venta: (Default)
[personal profile] venta
Does anyone know anything about .NET ?

I'm writing a .NET app (Managed C++) which manipulates registry keys. Which is fine.

You call GetValue on the subkey, passing in the name of the value you want to retrieve. The returned object is of type Sytem::Object, but you can cast it to an int or a string (depending on type) and all is well.

Except... what if your registry value is binary ? Then you can't cast it to an integer (it throws an exception, not unreasonably, presumably as it can't guarantee value is small enough to fit into an int). You are, in fact, left with a System::Object which is round, and smooth, and shiny and has absolutely no means of accessing the value contained therein.

At least, no means that I can determine. Just how do I persuade the binary value out of it ?

Date: 2008-04-03 04:10 pm (UTC)
From: [identity profile] erming.livejournal.com
I'm guessing you call the object's to string method then do stuff based on how you think it is encoded.

Date: 2008-04-03 04:23 pm (UTC)
From: [identity profile] venta.livejournal.com
ToString() returns "SytemByte*" where * is an unprintable character. I don't have much clue how I think it's encoded :(

Date: 2008-04-03 04:26 pm (UTC)
From: [identity profile] erming.livejournal.com
No but you could do

Image mypic = (Image)getValue().ToString() or something similar, where the binary is represented as an image.

but at the end of the day you need to know what the binary is meant to represent...

Date: 2008-04-03 04:31 pm (UTC)
From: [identity profile] venta.livejournal.com
It seems (see below) that the correct answer is to cast it to array<Byte>^ - something I'd tried to do already, but obviously got the syntax wrong (but wrong in such a way that it still compiled). Me and the hats don't get on so well yet :(
Edited Date: 2008-04-03 04:41 pm (UTC)

Profile

venta: (Default)
venta

December 2025

S M T W T F S
 123456
78910111213
14151617181920
212223 24252627
28293031   

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated Dec. 27th, 2025 12:34 pm
Powered by Dreamwidth Studios