There are two kinds of executable file in Windows, EXE file and DLL file. DLL (Dynamic Link Library) is an executable file with some procedures or functions in it. These procedures or functions can be used by some applications at the same time. Because, once DLL is loaded to memory, every program or application can use it. The other advantage of using DLL is our application becomes modular. It will be easier to change the application by replacing the DLL.
To create a DLL file, choose File – New – DLL. And you’ll get some codes below :
library Project1;
{ Important note about DLL memory management: ShareMem must be the first unit in your library's USES clause AND your project's (select Project-View Source) USES clause if your DLL exports any procedures or functions that pass strings as parameters or function results. This applies to all strings passed to and from your DLL--even those that are nested in records and classes. ShareMem is the interface unit to the BORLNDMM.DLL shared memory manager, which must be deployed along with your DLL. To avoid using BORLNDMM.DLL, pass string information using PChar or ShortString parameters. }
uses
SysUtils,
Classes;
{$R *.RES}
begin
end.
You can delete the unnecessary comment after library clause and add exports clause before begin….end block.
One thing you have to concern about is that all variables in DLL are private. Your application and DLL can not use the variables at the same time. You have to send values of the variables and receive a result.
Now we’re going to insert some functions into DLL :
library area_volume;
uses
SysUtils,
Classes;
{$R *.RES}
function area(length, width : integer): integer; stdcall;
begin
area := length*width;
end;
function volume(length, width, height : integer): integer; stdcall;
begin
volume := length*width*height;
end;
exports
area, volume;
begin
end.
You can download this source code here.
Now save the project as area_volume.dpr. Remember that the project name and the DLL name have to be the same, in this case we name it area_volume. Then build the DLL file by choosing Project – Build … And you’ll get area_volume.dll file. Then you can create an application using this DLL.
sungguh ini tutorial yang sangat membantu kita dalam memahami fungsi-fungsi.
ReplyDeletemoga sukses selalu kawan
Delphy, kok sulit c blajar nya. tolong sob, di posting mulai install , terus dasar2nya dan seterusnya..
ReplyDeleteijin copy ya sob..
ReplyDeleteTFS
@Pakde :thank you pakde :)
ReplyDelete@Ra'want : Its quite easy if you follow my tutorial in DELPHI(BEGINNER),see this blog archive. Installing Delphi is also simple, just like installing any other application (office ..etc) OK.. thank you for dropping by
@kakara : OK... thanks
s The best and a lot of secret drop-shipping suppliers in the world which will provide your products globally available for you directly to your customers doors. Also get the best drop-shipping manufacturer on your organization.
Delete