Document and Olevariant

xiaoxiao2021-03-06  72

// -------------------------- read data to olevariant // pfilename: File name with path Function getobj (PfileName: String): Olevariant; var fs: tfilestream; begin fs: = tfilestream.create (pfilename, fmopenread); try result: = varRraycreate ([0, fs.size-1], varbyte); fs.position: = 0; fs.readbuffer Vararraylock (Result) ^, fs.size; finally fs.free; var; end;

// ---------------------------- From Olevariant Writing the new file Function WriteFileFromole (PfileName: String; Polevariant: Olevariant): Integer; var fs: TFileStream; begin result: = 0; fs: = TFileStream.Create (pfileName, fmCreate); try try fs.WriteBuffer (varArrayLock (pOleVariant) ^, VarArrayHighBound (pOleVariant, 1) 1); except result: = - 1 End; Finally Fs.Free; Vararrayunlock (Polevariant); end;

------------------------------ Function Description: // Take the length of the DiM dimension of array A Function VaRRAYHIGHBOUND (Const A: Variant; DIM: Integer: Integer; // Create an array Function VararrayCreate (Const Bounds: Array Of Integer; VARTYPE: Integer): VARIANT;

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

New Post(0)