关于dll中调用弹出式菜单popupmenu的问题
云孤天 2004-10-18 01:56:18 动态库源码如下:
library ExportToZJJ;
{ 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,
Forms,
Messages,
Variants,
Windows,
Classes,
USetting in 'USetting.pas',
FormASProgress in 'FormASProgress.pas' {FrmASProgress},
ArchiveWfFrm in 'ArchiveWfFrm.pas' {FrmArchiveWf},
MainFrm in 'MainFrm.pas' {FrmMain},
ArchiveYhFrm in 'ArchiveYhFrm.pas' {FrmArchiveYh};
{$R *.res}
var
DLLApp: TApplication;
DLLScreen: TScreen;
procedure InportAndExport(aApp: TApplication; Scr: TScreen); stdcall;
begin
Application := aApp;
Screen := Scr;
try
Application.CreateForm(TFrmMain, FrmMain);
FrmMain.ShowModal;
FreeAndNil(FrmMain);
except
end;
end;
function ReadDLLInfo(): Pchar; stdcall;
begin
Result := MyCaption;
end;
procedure DLLUnloadProc(dwReason: DWORD);
begin
if dwReason = DLL_PROCESS_DETACH then begin
Application := DLLApp; //恢复
Screen := DLLScreen;
end;
end;
exports
InportAndExport,
ReadDLLInfo;
begin
DLLApp := Application; //保存 DLL 中初始的 Application 对象
DLLScreen := Screen;
DLLProc := @DLLUnloadProc; //保证 DLL 卸载时恢复原来的 Application
DLLUnloadProc(DLL_PROCESS_DETACH);
end.
现在的问题是我在动态库的窗体中加了一个popupmenu,但是只要涉及到popupmenu弹出的地方,一点就会提示地址错误,请问这是什么原因?有什么办法能解决吗