我想写一个DLL,并且在输出函数中要传递记录或数组参数而且要有对话框。我只知道需要用什么sharemem单元。求高手给完整源代码演示。非常感谢。
解决方案 »
- 再追加100分,关于这段代码哪里需要修改?一共200分...
- fastreport打印主从表的问题。
- 美国中央情报局在中国的最新发现
- 大虾救我,我是新手,分也不多,如果实在分不多,我可以把我得100全给!
- 关于Delphi程序做成Setup安装文件后,加密的问题!急,请帮忙!
- 求助excel怎么连接(急)
- 谁有水晶报表的安装CD-KEY???
- listview中dbclick中如何取得被双击的项?
- 请教:用DCOM开发三层应用
- 我用SHFileOperation进行文件拷贝的时候出现问题
- ado下如何实现batmove?
- 我用delphi编写源程序打包后变成A1.exe,怎么在windows环境下按F5键运行A1?
SysUtils,
Classes,
uDialog in 'uDialog.pas' {FDialog};{$R *.res}exports
GetData;begin
end.
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls;type
TFDialog = class(TForm)
RadioGroup1: TRadioGroup;
LabeledEdit1: TLabeledEdit;
BtnOK: TButton;
BtnCancel: TButton;
private
{ Private declarations }
public
{ Public declarations }
end; TData = array [1..1000] of Extended;function GetData(Par: Integer): TData; cdecl;implementation{$R *.dfm}procedure InitData(var D: TData);
var
I: Integer;
begin
for I := 1 to 1000 do D[I] := 0;
end;procedure SetData(Rand: Boolean; var D: TData);//加入其他参数,根据需要设置数据
var
I: Integer;
begin
if Rand then begin
for I := 1 to 1000 do
D[I] := Random(100)/100;//假定只需要0.00到0.99,小数点两位。
end else begin
end;
end;function GetData(Par: Integer): TData;
var
Data: TData;
begin
InitData(Data);
with TFDialog.Create(Application) do try
case ShowModal of
mrOK: case RadioGroup1.ItemIndex of
0: begin//Default
end;
1: begin//Input
end;
else
end;
mrCancel: case RadioGroup1.ItemIndex of
0: begin//Default
end;
1: begin//Input
end;
else
end;
else
SetData(True, Data);
end;
finally
Free;
end;
Result := Data;
end;end.
Forms,
uCall in 'uCall.pas' {FCall};{$R *.res}begin
Application.Initialize;
Application.CreateForm(TFCall, FCall);
Application.Run;
end.
顺便再问小可,为什么没有使用sharemem呢?
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;type
TFCall = class(TForm)
Label1: TLabel;
EditParam: TEdit;
BtnCall: TButton;
ResultMemo: TMemo;
procedure BtnCallClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
FCall: TFCall;implementation{$R *.dfm}type
TData = array [1..1000] of Extended;function GetData(Par: Integer): TData; cdecl; external 'MyDLL.dll' name 'GetData';procedure TFCall.BtnCallClick(Sender: TObject);
var
Data: TData;
I: Integer;
begin
Data := GetData(StrToInt(EditParam.Text));
for I := 1 to 1000 do
ResultMemo.Lines.Append(FormatFloat('0.00', Data[I]));
end;end.
TData = array [1..1000] of Extended;function GetData(Par: Integer): TData; cdecl; external 'MyDLL.dll' name 'GetData';ShareMem不是必须使用的单元。只有不同的应用程序实例需要通过公共的内存区域传递数据时,才需要使用该单元。