What's wrong with the code you posted Imaginary? Isn't it doing what your trying to do now? (cast to and from handle's and object's)
(For reference)
Local a:mytype=New mytype
Local b:Int=Int(a) 'convert to int handle
'Do whatever you want with the handle here
local a=VarPtr(b)[0] 'convert to object