太
太阳河上
Unregistered / Unconfirmed
GUEST, unregistred user!
各位高手:
这是我编写的Dll调用程序,但在调用时有总是出现:
第一个错误窗口:
应用程序发生异常未知的软件 异常(0x0eedfade),位置为0x77e69b01
第二个错误窗口:
"0x005c3a3e"指令引用的"0x0155c014"内存。该内存不能为"read"
我调用的如下:
1。做好了一个Xjgl的项目文件,主界面是XjglMainForm,现要把Xjgl做成Dll文件,给其它
调用。
2。生成Dll文件过程
library Xjgl;
{ 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,
Classes,
ActiveX,
XjglExport in 'XjglExport.pas';
{$R *.res}
begin
CoInitialize(nil);
end.
unit XjglExport;
interface
uses Windows, Messages,XjglMain,Forms;
procedure CreateXjgl(Appt: THandle;User,Pass: String); stdcall;
exports
CreateXjgl Index 1 Name 'CreateXjgl' Resident;
implementation
procedure CreateXjgl(Appt: THandle;User,Pass: String);
begin
Application.Handle:=Appt;
try
XjglMainForm:=TXjglMainForm.Create(Application);
XjglMainForm.puUser:=User;
XjglMainForm.puPass:=Pass;
XjglMainForm.ShowModal;
if XjglMainForm<>nil then
begin
//Application.MessageBox('Free!','提示',mb_ok);
XjglMainForm.Free;
XjglMainForm:=nil;
end;
except
//XjglMainForm.Free;
Application.MessageBox('无法创建实例!','提示',mb_ok);
end;
end;
end.
3.调用Dll文件过程
unit JwglMain;
interface
implementation
uses DllUnit,Fnuc,JwglData;
{$R *.dfm}
procedure TJwglMainForm.HemisphereButton1Click(Sender: TObject);
begin
//Application.Terminate;
Close;
end;
procedure TJwglMainForm.GrapLabel1Click(Sender: TObject);
var FPro: TFarProc;
Moudle: THandle;
Path: String;
begin
try
with JwglDM.Client10 do
begin
Close;
CommandText:='SELECT * FROM Xjglyhb WHERE (Jsdm='+QuotedStr(Edit1.Text)+
') AND (Qx4='+QuotedStr(Edit2.Text)+')';
Open;
if RecordCount>0 then
CreateXjgl(Application.Handle,Edit1.Text,Edit2.Text)
else Application.MessageBox('没有权限进入本系统!','提示',mb_ok);
end;
except
end;
end;
end.
unit DllUnit;
interface
procedure CreateXjgl(Appt: THandle;User,pass: String); Stdcall;
procedure CreateJxjhgl(Appt: THandle;User,pass: String); Stdcall;
implementation
Procedure CreateXjgl(Appt: THandle;User,pass: String);far; External 'Xjgl.dll' name 'CreateXjgl';
Procedure CreateJxjhgl(Appt: THandle;User,pass: String);far; External 'Jxjhgl.dll' name 'CreateJxjhgl';
end.
哪位高手指点一下?
这是我编写的Dll调用程序,但在调用时有总是出现:
第一个错误窗口:
应用程序发生异常未知的软件 异常(0x0eedfade),位置为0x77e69b01
第二个错误窗口:
"0x005c3a3e"指令引用的"0x0155c014"内存。该内存不能为"read"
我调用的如下:
1。做好了一个Xjgl的项目文件,主界面是XjglMainForm,现要把Xjgl做成Dll文件,给其它
调用。
2。生成Dll文件过程
library Xjgl;
{ 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,
Classes,
ActiveX,
XjglExport in 'XjglExport.pas';
{$R *.res}
begin
CoInitialize(nil);
end.
unit XjglExport;
interface
uses Windows, Messages,XjglMain,Forms;
procedure CreateXjgl(Appt: THandle;User,Pass: String); stdcall;
exports
CreateXjgl Index 1 Name 'CreateXjgl' Resident;
implementation
procedure CreateXjgl(Appt: THandle;User,Pass: String);
begin
Application.Handle:=Appt;
try
XjglMainForm:=TXjglMainForm.Create(Application);
XjglMainForm.puUser:=User;
XjglMainForm.puPass:=Pass;
XjglMainForm.ShowModal;
if XjglMainForm<>nil then
begin
//Application.MessageBox('Free!','提示',mb_ok);
XjglMainForm.Free;
XjglMainForm:=nil;
end;
except
//XjglMainForm.Free;
Application.MessageBox('无法创建实例!','提示',mb_ok);
end;
end;
end.
3.调用Dll文件过程
unit JwglMain;
interface
implementation
uses DllUnit,Fnuc,JwglData;
{$R *.dfm}
procedure TJwglMainForm.HemisphereButton1Click(Sender: TObject);
begin
//Application.Terminate;
Close;
end;
procedure TJwglMainForm.GrapLabel1Click(Sender: TObject);
var FPro: TFarProc;
Moudle: THandle;
Path: String;
begin
try
with JwglDM.Client10 do
begin
Close;
CommandText:='SELECT * FROM Xjglyhb WHERE (Jsdm='+QuotedStr(Edit1.Text)+
') AND (Qx4='+QuotedStr(Edit2.Text)+')';
Open;
if RecordCount>0 then
CreateXjgl(Application.Handle,Edit1.Text,Edit2.Text)
else Application.MessageBox('没有权限进入本系统!','提示',mb_ok);
end;
except
end;
end;
end.
unit DllUnit;
interface
procedure CreateXjgl(Appt: THandle;User,pass: String); Stdcall;
procedure CreateJxjhgl(Appt: THandle;User,pass: String); Stdcall;
implementation
Procedure CreateXjgl(Appt: THandle;User,pass: String);far; External 'Xjgl.dll' name 'CreateXjgl';
Procedure CreateJxjhgl(Appt: THandle;User,pass: String);far; External 'Jxjhgl.dll' name 'CreateJxjhgl';
end.
哪位高手指点一下?