D6 and REG_MULTI_SZ registry data

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

D6 and REG_MULTI_SZ registry data

Don Rylander-3
Blair or Andy,

Will D6 support REG_MULTI_SZ registry data?  I noticed I'd modified
RegKeyAbstract>>valueFromObject: and #objectFromValue:type:size: to handle
it back in 2002, but I keep worrying I'm going to obliterate a better
implementation with my automatic file-in.  Or have I already?

I've included my crude-but-effective solution below.  Unfortunately, I don't
have tests, but maybe it'll be helpful if you haven't already solved the
problem.

Thanks,

Don

===========================
!RegKeyAbstract methodsFor!

objectFromValue: bytes type: type size: size
 "Private - Instantiate an appropriate object to represent the registry
 value with the specified type, content, and size."

 #todo "Add other registry types".

 (type == REG_SZ or: [type == REG_EXPAND_SZ]) ifTrue: [^bytes copy: String
from: 1 to: (size-1 max: 0)].
 #drModified. "Added handling for REG_MULTI_SZ - No standard yet?"
 type == REG_MULTI_SZ ifTrue: [^(bytes copy: String from: 1 to: (size-1 max:
0)) subStrings: Character null].
 type == REG_DWORD ifTrue: [^bytes dwordAtOffset: 0].
 type == REG_BINARY ifTrue: [^bytes copyFrom: 1 to: size].
 type == REG_NONE ifTrue: [^nil].
 Notification signal: 'Unrecognised registry value type treated as binary:
', type printString.
 ^bytes copyFrom: 1 to: size!

valueFromObject: value
 "Private - This is nasty, but we don't want to modify the base classes to
support
 a conversion function..."

 "Add other registry types"

 #todo.
 value isNil ifTrue: [^REG_NONE -> #[]].
 (value isKindOf: Integer) ifTrue: [^REG_DWORD -> (DWORD fromInteger:
value)].
 (value isKindOf: String) ifTrue: [^REG_SZ -> value].
 #drModified. "Added handling for REG_MULTI_SZ - No standard yet?"
 ((value isKindOf: Collection) and: [(value detect: [:e | e isKindOf:
String] ifNone: []) notNil])
   ifTrue: [|ws|
    ws := String writeStream.
    value do: [:line |ws
       nextPutAll: line;
       nextPut: Character null].
    ^REG_MULTI_SZ -> ws contents].
 ^REG_BINARY -> value asByteArray! !
!RegKeyAbstract categoriesFor: #objectFromValue:type:size:!helpers!private!
!
!RegKeyAbstract categoriesFor: #valueFromObject:!helpers!private! !


Reply | Threaded
Open this post in threaded view
|

Re: D6 and REG_MULTI_SZ registry data

Schwab,Wilhelm K
Don, Andy, Blair,

> Will D6 support REG_MULTI_SZ registry data?  I noticed I'd modified
> RegKeyAbstract>>valueFromObject: and #objectFromValue:type:size: to handle
> it back in 2002, but I keep worrying I'm going to obliterate a better
> implementation with my automatic file-in.  Or have I already?

Rather than testing on type, I suspect it would be nicer to dispatch
reads and writes through a minority of classes whose instances can "fit"
in the registry.  Those that don't fit would raise DNU or should not
implement exceptions, but it should help in extending the framework.

Have a good one,

Bill

--
Wilhelm K. Schwab, Ph.D.
[hidden email]