Delphi Variant oleVariant

The OleVariant type exists on both the Windows and Linux platforms. The main difference between Variant and OleVariant is that Variant can contain data types that only the current application knows what to do with. OleVariant can only contain the data types defined as compatible with OLE Automation which means that the data types that can be passed between programs or across the network without worrying about whether the other end will know how to handle the data.



When you assign a Variant that contains custom data (such as a Delphi string, or a one of the new custom variant types) to an OleVariant, the runtime library tries to convert the Variant into one of the OleVariant standard data types (such as a Delphi string converts to an OLE BSTR string). For example, if a variant containing an AnsiString is assigned to an OleVariant, the AnsiString becomes a WideString. The same is true when passing a Variant to an OleVariant function parameter.
olevariant存在于windows和linux平台,这二种类型主要的不同是variant类型仅是当前的应用程序可以进行操作,而olevariant类型则是ole自动化服务器所以定义的统一的数据类型,意味着可以通过网络或其他程序进行操作,当然也不必担心其他客户端如何进行操作.



当你给一个variant类型的变量赋自定义的值的时候(例如delphi string,或一个其他的新的自定义类型),运行时间库将试着将他转化为olevariant标准数据类型(例如string转化为 OLE BSTR string),例如,一个包括Ansistring数据的variant类型斌值给olevariant,ansiString将成为WideString,当把variant传为olevariant的函数参数也是一样的.

 

你可能感兴趣的:(Delphi)