呵呵,好像只有类才支持RTTI吧,其它类型好像不支持, 不过,Pascal是强类型语言,你的普通变量的类型在编译前就应确定了呀,要不然编译会通不过的!
如果你要支持多种类型,就用变体吧(Variant)

解决方案 »

  1.   

    function VarType(const V: Variant): TVarType;
      

  2.   

    VarType Contents of variantvarEmpty The variant is Unassigned.
    varNull The variant is Null.
    varSmallint 16-bit signed integer (type Smallint).
    varInteger 32-bit signed integer (type Integer).
    varSingle Single-precision floating-point value (type Single).
    varDouble Double-precision floating-point value (type Double).
    varCurrency Currency floating-point value (type Currency).
    varDate Date and time value (type TDateTime).
    varOleStr Reference to a dynamically allocated UNICODE string.varDispatch Reference to an Automation object (an IDispatch interface pointer).
    varError Operating system error code.
    varBoolean 16-bit boolean (type WordBool).
    varVariant A variant.
    varUnknown Reference to an unknown OLE object (an IInterface or IUnknown interface pointer).
    varShortInt 8-bit signed integer (type ShortInt)
    varByte A Byte
    varWord unsigned 16-bit value (Word)
    varLongWord unsigned 32-bit value (LongWord)
    varInt64 64-bit signed integer (Int64)varStrArg COM-compatible string.
    varString Reference to a dynamically allocated string (not COM compatible).
    varAny A CORBA Any value.
      

  3.   

    var  V: Variant;
    begin
      ...
      try
        V := MyFunction();  //取得返回值
        case VarType(V) of
         varEmpty: // The Variant is Unassigned.
         varNull:  // The Variant is Null.
         varSmallint: // 16-bit signed integer (type Smallint).
         varInteger:  // 32-bit signed integer (type Integer).
         varSingle:   // Single-precision floating-point value (type Single).
         varDouble:  // Double-precision floating-point value (type Double).
        .......
      except
        //转换不成功,应处理此异常
      end;
    end;
      

  4.   

    function VarType(const V: Variant): TVarType;VarType Contents of variantvarEmpty The variant is Unassigned.
    varNull The variant is Null.
    varSmallint 16-bit signed integer (type Smallint).
    varInteger 32-bit signed integer (type Integer).
    varSingle Single-precision floating-point value (type Single).
    varDouble Double-precision floating-point value (type Double).
    varCurrency Currency floating-point value (type Currency).
    varDate Date and time value (type TDateTime).
    varOleStr Reference to a dynamically allocated UNICODE string.varDispatch Reference to an Automation object (an IDispatch interface pointer).
    varError Operating system error code.
    varBoolean 16-bit boolean (type WordBool).
    varVariant A variant.
    varUnknown Reference to an unknown object (an IInterface or IUnknown interface pointer).
    varShortInt 8-bit signed integer (type ShortInt)
    varByte A Byte
    varWord unsigned 16-bit value (Word)
    varLongWord unsigned 32-bit value (LongWord)
    varInt64 64-bit signed integer (Int64)varStrArg COM-compatible string.
    varString Reference to a dynamically allocated string.
    varAny A CORBA Any value.