关掉调用DLL的主窗口时就报告Invalid pointer operation
全文:http://bbs.csdn.net/topics/40485751
亲测如下:
1.在 dll 的 uses 部分添加 ShareMem 单元。例如:
library Project1; { 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 ShareMem, SysUtils, IdHTTP, Classes; {$R *.res} function GetText(Site:string):string; stdcall; var idhtp1:TIdHTTP; HTMLList:TStringList; begin HTMLList := TStringList.Create; idhtp1 := TIdHTTP.Create(nil); HTMLList.Text := idhtp1.Get(Site); Result := HTMLList.Text; idhtp1.Free; HTMLList.Free; end; exports GetText; begin end.
2.在 exe 的 project->view source、在DPR文件中 uses 部分添加 ShareMem 单元。例如:
program Project11; uses ShareMem, Forms, Unit1 in 'Unit1.pas' {Form1}; {$R *.res} begin Application.Initialize; Application.CreateForm(TForm1, Form1); Application.Run; end.