dll代码如下(是一个最简短的一个返回字串的dll,我是学习书上写的):
library xtSql; { 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; {$R *.res}
function GetSqlConnStr():string; stdcall; begin result:='Driver=SQL Server;Server=jerker;UID=sa;PWD=sa;DataBase=H_Jerker'; end;
exports GetSqlConnStr; begin
end.
程序的部分代码如下: {$R *.dfm}
function GetSqlConnStr():string; stdcall;
external 'xtSQL.DLL' function GetConnString():string;
begin
ShowMessage(GetSqlConnStr());
GetConnString := 'Driver=SQL Server;Server=jerker;UID=sa;PWD=sa;DataBase=H_Jerker'; //GetConnString := GetSqlConnStr();
end; // 打开连接对象
procedure ConnOpen();
begin
with Form_ResList do
begin
ADOConn_Manage.ConnectionString := GetConnString();
ADOConn_Manage.LoginPrompt := false;
ADOConn_Manage.Connected := true;
end
end;
调用ConnOpen();的时候,就有错误,
错误出现在ADOConn_Manage.ConnectionString := GetConnString();
ShowMessage(string(GetSqlConnStr()))能弹出信息;后就提示错误!
去掉就一切正常!
我是一个初学者,刚接触Delphi,所以拜托各位了!谢谢!
library xtSql; { 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; {$R *.res}
function GetSqlConnStr():string; stdcall; begin result:='Driver=SQL Server;Server=jerker;UID=sa;PWD=sa;DataBase=H_Jerker'; end;
exports GetSqlConnStr; begin
end.
程序的部分代码如下: {$R *.dfm}
function GetSqlConnStr():string; stdcall;
external 'xtSQL.DLL' function GetConnString():string;
begin
ShowMessage(GetSqlConnStr());
GetConnString := 'Driver=SQL Server;Server=jerker;UID=sa;PWD=sa;DataBase=H_Jerker'; //GetConnString := GetSqlConnStr();
end; // 打开连接对象
procedure ConnOpen();
begin
with Form_ResList do
begin
ADOConn_Manage.ConnectionString := GetConnString();
ADOConn_Manage.LoginPrompt := false;
ADOConn_Manage.Connected := true;
end
end;
调用ConnOpen();的时候,就有错误,
错误出现在ADOConn_Manage.ConnectionString := GetConnString();
ShowMessage(string(GetSqlConnStr()))能弹出信息;后就提示错误!
去掉就一切正常!
我是一个初学者,刚接触Delphi,所以拜托各位了!谢谢!
解决方案 »
- 关于决策支持控件(如统计图等),求推荐
- 请问在listview中统计问题??
- C/S中客户端数据一致性???
- 主从表中主表移动记录时,会触发从表什么事件?
- TQuery,TDBGird,TDataSource三者如何联,各自属性怎么设置啊?我是初学者
- 怎么解决动态链接库中的string问题?
- 中间件问题!
- Datetimepicker问题
- 如何取到opendialog1.FileName不包括路径的文件名?(急)
- 我用ADOTable.ActiveBuffer无法获取正确结果
- 请问,特定窗口内的鼠标钩子怎么做?
- 求救!!如何在delphi中控制windows的有关操作!!急!在线等!100份!!
只能用Pchar类型,就是指针了明白了吗:)