Different between BPL and DLL

Source: Internet
Author: User

Previously, for the differences between BPL and DLL, it has always been a comprehensive solution, most of which (I have read), even if it is better than the typical Delphi solution, it's also vague! Thanks to the help in finding a better description !!!

That is correct. a BPL is a DLL. (but not all DLLs are bpls .)

> But I still found some different, such as that I can create
> Object from the host EXE and that pass to a BPL and modify it safely,
> If I do same to a DLL, I can not modify any referenced property of the object.

> But I still found some differences, such as I can create a object under the host EXE,
> It cocould be transfer to BPL and modified safely, but I can not do the same thing with DLL
> Cause the referenced properties can not be modified correctly under it.

When you use packages, There is only ever one copy of any unit in
Memory. One copy of forms, one copy of sysutils, one copy of System
(Well, most of it), one copy of stdctrls, etc.

All class-related operations, such as the "is" and "as" operators, rely
On class references. Class references are actually just addresses. They
Point to definitions for the layouts of the classes 'internals. (They
Point to what's called the virtual-method table, the VMT.) Two Classes
Are the same if they point to the same VMT -- if the addresses are equal.

When you have a class defined in the EXE's copy of stdctrls and the same
Class defined in a DLL's copy of stdctrls, those classes will really
Have different addresses. The "is" and "as" operators won't work
Cross-module clases. But when you use packages, there is only one copy
Of the class, kept in vcl70.bpl, so all modules that reference that
Package will share a single class definition.

Another factor is the memory manager in system. All string allocations
Ultimately call getmem and freemem. If the EXE allocates a string, it
Uses its own getmem. It then passes the string to a DLL, And the DLL
Might try to free it. The dll will call its own copy of freemem, which
Won't have access to the EXE's memory-manager structures, and you'll get
Errors. With packages, everything will use the same memory manager from
Rtl70.bpl. (This can also be solved by using a Shared Memory Manager
Between the EXE and the DLL; sharemem is one example. That won't solve
The class-comparison problem, though .)

Above, I said the major difference between bpls and DLLs is the number
Of exported functions. With a DLL, the only things exported are what
Appear in the "exports" clause that you write yourself. With a BPL,
Everything from all the units '"interface" sections gets exported,
Including global variables and class definitions. Also exported are
Addresses of the "initialization" and "finalization" sections. And,
Internally, that is indeed the major difference. a bpl exports
Functions necessary for the RTL to recognize the file as being a BPL and
Not just a generic DLL. If you call loadpackage, I will call loadlibrary
To load it like a normal DLL, and then it will call all the package's
Units 'initialization sections and do a Fe other housekeeping
Operations. Calling a package's functions generates the same kind
Extends er code as is generated when you call a DLL function.

--
Rob

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.