dll编程问题(急急!!)(50分)

G

gao_ad

Unregistered / Unconfirmed
GUEST, unregistred user!
我编写里一个动态库,在delphi的程序中调用没有问题,但是在pb中调用就出错。请各位打侠指教。
library count_table6;
{ 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
Windows,
SysUtils,
Dialogs,
Forms,
Classes,
ib_DataModule in 'ib_DataModule.pas' {DataModule1: TDataModule};
//******************************************************//
// 函数名称:list_table6
//参数:project_name,start_date:string 工程名称 ,统计起始时间
//返回值:integer 0 有结果 ,1 没有结果
//******************************************************//
function list_table6(project_name,start_date:string):integer;stdcall;
begin
//生成数据模块
showmessage('create DataModule');
DataModule1 := TDataModule1.Create(nil);
showmessage('retrieve data');
//返回结果
Result := DataModule1.list_table6(project_name,start_date);
showmessage('retrieve end');
DataModule1.Destroy;
showmessage('destory DataModule');
end;

exports
list_table6;
{$R *.res}
begin

end.
 
你PB的调用接口贴出来看看。
 
//声明
Function int list_table6(string project_name,string start_date) LIBRARY "count_table6.dll"
//调用
//**************************************************************//
//检索表六数据,将其写入指定的文件
string project_name,start_date
int table6_no
project_name = ''
start_date = '2003-01-01'
table6_no = list_table6(project_name,start_date)
//**************************************************************//
 
Cowboy Blues:不在吗???
 
改为如下:
function list_table6(project_name,start_date:pchar):integer;stdcall;
begin
//生成数据模块
DataModule1 := TDataModule1.Create(nil);
//返回结果
Result := DataModule1.list_table6(string(project_name),string(start_date));
DataModule1.Destroy;
end;

========================================================
调用:
Function int list_table6(string project_name,string start_date) LIBRARY "count_table6.dll"
 
对数据库的操作有什么pb作不了的呢?还用dll
 
非常感谢各位的关注,尤其是9903朋友。问题已解决,能告诉我为什么吗?
 
我的数据库有一部分是InterBase的,我没他的odbc驱动。
 
因为delphi和pb管理string类型的方式不同,
关于数据类型的定义,你可以看下<delphi5开发人员指南>中关于数据类型的部分.
 
谢谢9903
 
顶部