Форум: "WinAPI";
Текущий архив: 2002.06.06;
Скачать: [xml.tar.bz2];
ВнизФорма в DLL... В чем ошибка??? Найти похожие ветки
← →
Sirus (2002-04-03 15:30) [0]Привет ВСЕМ кто читает!!!
Создал форму в DLL... пытаюсь вызвать ее из программы...
загружаю DLL вызываю процедуру, которая показывает мне форму... все работает...
А вот когда закрываю форму выскакивает ошибка Access violation...
Подскажите как лечить...
← →
Suntechnic (2002-04-03 16:37) [1]Код в студию. Особенно интересуют места, где форма создаётся и где именно удаляется.
← →
Sirus (2002-04-04 06:20) [2]Вот код DLL проекта...
library proba;
uses
Windows,
SysUtils,
forms,
Classes,
main in "main.pas" {AForm};
function MainFormShowModal(Capt:string):integer; stdcall;
Begin
AForm:=TAForm.Create(Application);
Result:=AForm.ShowModal;
AForm.Free;
End;
{$R *.RES}
exports MainFormShowModal;
begin
end.
А это код формы в DLL
unit main;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls;
type
TAForm = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
AForm: TAForm;
implementation
{$R *.DFM}
procedure TAForm.Button1Click(Sender: TObject);
begin
ShowMessage("Hello! This is a DLL form and message");
end;
end.
Исходник проекта вызывающего форму...
unit dmunit;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
MainFormShowModal:procedure(Capt:String);
LibHandle: THandle;
implementation
{$R *.DFM}
procedure TForm1.Button1Click(Sender: TObject);
begin
@MainFormShowModal := nil;
LibHandle := LoadLibrary("proba.dll");
if LibHandle >= 32 then begin
@MainFormShowModal := GetProcAddress(LibHandle,"MainFormShowModal");
if @mainFormShowModal <> nil then
MainFormShowModal("Hello");
end;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
FreeLibrary(LibHandle);
end;
end.
Прошу... Посоветуйте что можете... Седня я должен добить эту проблему...
← →
Suntechnic (2002-04-04 07:07) [3]Ты читал, что Delphi для тебя пишет, когда ты dll создаёшь?
{ 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. }
Приведи свой код в соответствие, а там дальше видно будет, всё остальное вроде в порядке на первый взгляд.
Страницы: 1 вся ветка
Форум: "WinAPI";
Текущий архив: 2002.06.06;
Скачать: [xml.tar.bz2];
Память: 0.45 MB
Время: 0.007 c