You should be able to do this by returning a union of different datatypes similar to the VARIANT structure. See here - VARIANT and VARIANTARG