String and VariantaRray

xiaoxiao2021-03-06  64

Function StringtovariantArray (const s: string): olevariant; var p: pointer; begin result: = null; if longth (s)> 0 thrrete ([0, Length (s) - 1], varbyte; P: = VararrayLock (Result); Try Move (S [1], P ^, Length (s)); Finally Vararrayunlock (Result); end; end;

function VariantArrayToString (const V: OleVariant): string; var P: Pointer; Size: Integer; begin Result: = ''; if VarIsArray (V) and (VarType (V) and varTypeMask = varByte) then begin Size: = VarArrayHighBound ( V, 1) - VararraylowBound (V, 1) 1; if size> 0 Then Begin setlength (result, size); p: = varraylock (v); try move (p ^, result [1], size); Finally Vararrayunlock (v); end; end; end;

转载请注明原文地址:https://www.9cbs.com/read-118813.html

New Post(0)