发信人: kingfox()
整理人: jchao(2000-01-13 12:37:01), 站内信件
|
【 在 cobe (<marquee>就爱VB) 的大作中提到: 】
: 我想用DELPHI建立一个DLL文件,然后用VB调用,不知能否实现?
: 如果可以,DLL文件书写格式是什么样的??
:
: 多谢多谢
: .......
完全可以,不过详细的说明一言难尽,可以参见Delphi的联机文档。
下面是其中的一部分
Writing DLLs
Topic groups See also
The structure of a DLL is identical to that of a program, except that a DLL begins with the reserved word library (instead of program).
The following example shows a DLL with two exported functions, Min and Max.
library MinMax;
function Min(X, Y: Integer): Integer; stdcall;
begin
if X < Y then Min := X else Min := Y;
end;
function Max(X, Y: Integer): Integer; stdcall;
begin
if X > Y then Max := X else Max := Y;
end;
exports
Min,
Max;
begin
end.
If you want your DLL to be available to applications written in other languages, it’s safest to specify stdcall in the declarations of expo rted functions. Other languages may not support Object Pascal’s defau lt register calling convention.
DLLs can be built from multiple units. In this case, the library sourc e file is frequently reduced to a uses clause, an exports clause, and the DLL’s initialization code. For example,
library Editors;
uses EdInit, EdInOut, EdFormat, EdPrint;
exports
InitEditors,
DoneEditors index 17 name Done,
InsertText name Insert,
DeleteSelection name Delete,
FormatSelection,
PrintSelection name Print,
...
SetErrorHandler;
begin
InitLibrary;
end.
You can put exports clauses in the interface or implementation section of a unit. Any library that includes such a unit in its uses clause a utomatically exports the routines listed the unit’s
exports clauses—without the need for an exports clause of its own.
Only routines that a library explicitly exports are available for impo rting by other libraries or programs.
-- ------------------------------------------------------------
有缘则聚,缘尽则散,随缘而定,随遇而安。
------------------------------------------------------------
欢迎光临“电子工程师园地”http://kingfox.163.net
※ 来源:.月光软件站 http://www.moon-soft.com.[FROM: 202.96.243.80]
|
|