I've translated a few articles about UDF, although some friends may get some help, but it's possible that the UDF
There are still some problems in understanding. Today, I translate two articles, both of which are from Mer System (http://www.mers.com)
, interested friends can view the original.
[Argument]:
When a dynamic-link library does not have special precautions for protected data values, our UDF has data results with parameter values or return values
May be in a protected exception or error result.
[Solution]:
Each date value is saved in two 32-bit integer types: A signed integer representing the date, and a representation
The unsigned integer of the time. Use the Delphi code to define this structure (ISC_QUAD) and the pointer to the 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;
To protect the return value, declare a thread-safe isc_quad variable outside the function definition so that it holds 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 the thread variable.
Defining functions
This function adds a 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
The main source: MER Systems Inc. Http://www.mers.com
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.