Transfer and return data to a Delphi written UDF

zhaozj2021-02-16  45

[UDF Series on]: passing and returning data to a Delphi translation of written UDFWarton: Chris Levesque, Tina Grubbe, Brett Bandy

-------------------------------------------------- ------------------------------

[Translator's narrative]:

I have translated a few articles about writing UDF, although some friends may have helped it, but there may be some problems with UDF. Today, I translate two articles, these two articles are from mercym (http://www.mers.com), interested friends can view the original text.

[Disciple]: When the dynamic link library does not make special prevention for protected data values, our UDF has a parameter value or the return value of data may be in a protected exception or error result. [Solution]: Each date value is saved in two 32-bit integer types: a Signed Integer that represents the date, and a unsigned integer that represents time. Using Delphi code to define a pointer to this structure (ISC_QUAD) and structure (PISC_QUAD): type {InterBase Date / Time Record} ISC_QUAD = record isc_quad_high: Integer; // Date isc_quad_low: Cardinal; // Time end; PISC_QUAD = ^ ISC_QUAD; In order to protect the return value, a thread secure ISC_QUAD variable is applied externally, so that it saves the return value (if the return value is a date type of data). Threadvar Tempquad: ISC_QUAD; then write your function so that the result points to thread variables. // defined functions // This function adds a number of days to an existing date function DayAdd (var Days: Integer; IBDate PISC_QUAD):. PISC_QUAD; cdecl; export; begin tempquad.isc_quad_high: = IBDate ^ .isc_quad_high Days; tempquad .isc_quad_low: = ibdate ^ .ISC_QUAD_LOW; Result: = @tempquad; END; This Lord comes from: Mer Systems Inc.. http://www.mers.com

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

New Post(0)