把两处function cre():boolean;far;export;中的far改为stdcall
解决方案 »
- 转贴一封:Delphi程序员现状(招聘感想、招聘试题)
- 怎样给名为edit1的edit组件赋值,怎样操作?谢谢!!!!!!!!!!
- 谁能介绍个Office2003风格的界面控件
- 有关构象方程
- ADO控件在线程中如何实现同步查询吗?
- 如何在DBEdit中 按下“上键”就跳转到上一个TabOrder???
- 各位,国庆节上那里玩去了?羡慕流口水Ing
- 如果让在dbgrid的一个cell里只能输入数字
- 大家都想知道程的序员待遇问题:所在地、薪水、工作性质。我们都在同一战壕上,面对老板我们心里应该有个数,想吹牛的朋友请您忍一忍。
- 怎么让一个窗口以独占的方式显示!!!!!
- 关于Delphi5的ADO
- 急!急!急!关于DLL中的MDI子窗体
function cre(): Boolean; stdcall;exports
cre;implementation
...在引用的时候不用声明了,只要在Uses中加上其单元即可。
1.设计一个新项目,在其中包含的单元中声名一个供外部程序调用的过程或函数。
这些和您原来写普通程序都一样。
2.不一样的是:您需要在单元程序的接口部分声名的函数或过程的后面增加这样的关键字:EXPORT;
3.修改项目的代码,1.改 program为library,2.改forms为sharemem,
3在USES后增加EXPORTS关键字,关键字后是调用的过程和函数名,一般为:
USES
EXPORTS
XXXXX;
{$R *.RES}
4.删除项目中BEGIN 、END之间的代码。
编译项目,就可以生成一个扩展名为DLL的动态连接库。调用动态连接库的方法刚好同制作对应,大体分为下列几点:
1.在单元程序的接口部分声明外部过程,形式参数必须和设计的动态连接库相同。
Procedure xxxxxx(var xxxx:xxx ;………);far;external 'xxxxxxx';
2.在单元程序中,您可以象使用函数一样使用外部单元,编写子过程和函数。
3.项目文件中,增加SHAREMEM到USES单元,实现内存共享。
VB、PB、Delphi 联合编程Delphi
Unit1 代码:unit Unit1;interfaceuses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.DFM}procedure TForm1.Button1Click(Sender: TObject);
begin
MessageDlg('This is a Delphi MessageDlg !',mtInformation,[mbOK],0);
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
self.Caption:='This is a Delphi Modal Form !';
self.Button1.Caption:='This is a Delphi Button !';
end;end.==========================
VB call Delphi Dll code:
'一定要声明为 Long,虽然在 Delphi Dll 定义的是 Procedure (过程)
Private Declare Function ShowDelphiFormModal Lib "..\..\Project1.dll" () As Long
Private Sub Command1_Click()
ShowDelphiFormModal
End Sub
==================
PB call Delphi Dll Code:
//'一定要声明为 Long,虽然在 Delphi Dll 定义的是 Procedure (过程)
FUNCTION long ShowDelphiFormModal () LIBRARY "..\..\Project1.dll"
...
ShowDelphiFormModal()
欢迎访问 http://simideal.top263.net
VB、PB、Delphi 联合编程