【发布时间】:2010-10-04 14:41:36
【问题描述】:
我之前曾向 another questions 询问过关于构建我的 dll 的问题,但它看起来像是朝着错误的方向 :) 所以我重新制定并解释了更多她。
所以我试图构建的是一个 dll,它将作为我的 delphi 程序和其他人的 C 程序之间的接口。
这个 dll 必须做的是从 C 程序接收一个字符串,然后将它发送到 delphi 程序,在那里它将与一些数据组合并存储在我程序的当前用户下。
如何在我的 Delphi 程序(运行程序)中调用方法来存储来自 dll 的消息?
我正在使用 Delphi 5。 这是我到目前为止得到的:
DLL:
//Parent application: MyDelphiApp
library MyDllLink;
uses
ShareMem,
SysUtils,
Classes,
Dialogs,
Main;// Main is a form from my delphi app. This is not allowed/recomended ?
{$R *.RES}
procedure Transfer(sMessage: PChar); stdcall;
begin
try
//If including Main in the uses clause, then this will also be wrong:
MainForm.StoreDllMessage(sMessage);
except
showmessage('Error');
end;
end;
exports
Transfer;
end.
德尔福应用:
procedure TMainForm.StoreDllMessage(sMessage: String);
begin
//StoreMessage just stores it in a DB
StoreMessage(sMessage +' '+sCurrentUserName);
end;
【问题讨论】: