Tutorials to .com

Tutorials to .com » Software » Delphi » Delphi on the use of reusable DLL file produced recommendations

Delphi on the use of reusable DLL file produced recommendations

Print View , by: iSee ,Total views: 24 ,Word Count: 738 ,Date: Sat, 22 Aug 2009 Time: 10:10 AM

Delphi on the use of the production of reusable DLL file recommendations
There are some in the company's need to produce a DLL of the occasion, because of the familiarity, convenience and easy to use delphi to create a majority. Now on the subject to make some personal recommendations.

To make full use of the standard DLL interface. Refers to the transfer function of the parameter types and return type can not be unique to Delphi, for example, string (AnsiString), as well as dynamic arrays and contain members of these types of composite types (such as records), it can not be members of these types contain data members object type, to avoid any possible mistakes. If you use a string type or types of dynamic arrays, and the caller is not a Delphi program, it will basically error. If the caller is a caller or Delphi but did not call the project file that contains the first unit is not ShareMem, may also be wrong.

If the caller is a Delphi application program, you may be able to use does not include the prohibition of the type (string, dynamic array) data members of object as a parameter or return value, but should also be avoided as far as possible.

If the caller and the caller are the Delphi process, but also to the use of string or dynamic arrays as parameters, it works both documents include the first unit to be ShareMem. (C + + Builder program may be the same, but not tested.)

If the caller is not a Delphi process, the string, dynamic array, string or dynamic array contains complex data types and types of examples, we can not as a parameter and return value.

Therefore, in order to improve the reuse of the scope of DLL to avoid errors that may exist, it should be using the standard WIN32 API standard parameters of the type previously used string variables, you can use PChar (s) conversion. Dynamic array conversion for pointer types (@ array [0]), and add the length of the array.

If the caller and the caller are Delphi procedures, in order to facilitate the preparation and did not want to carry out such conversion, the recommended form of run-time package. Run-time dynamic allocation of packet data to ensure that the correct release. Such as its extension (. Bpl), shows that the document is limited to Delphi / c + + Builder use (not as DLL).

Secondly, as far as possible avoid the use of the overload function / process for output, if there are multiple ways the same operation, it can function / process were a bit different, similar to Delphi's FormatXXXX, CreateXXXX such as functions and methods, such as CreateByDefaultFile, CreateDefault.

Finally, as the provider DLL, it should be to provide direct programming interface documents, such as Delphi's. Pas or. Dcu (preferably. Pas, because they can have the Notes), C++ and C + + in. H and. Lib. And not allow users to create their own. If you must have a function of overload / process, this point is of particular importance. In addition, as a Delphi application, provided. Pas file can be connected in advance (using the specified external output function in the DLL), the latter can also be connected (using LoadLibrary, GetProcAddress), DLL programming interface providers document, both it is a formal (or HiQoS), and security.


Delphi Tutorial Articles


Can't Find What You're Looking For?


Rating: Not yet rated

Comments

No comments posted.