//////////dll中是这样声明的:
function ReadDbInfo(section:string;databasetype:integer):string;
var
MyIniFile: TIniFile;
PassWord,UserID,DataSource,Defaultdb,ss:string;
begin MyIniFile := TIniFile.Create('C:\CJSMS\DBINFO.ini');
if databasetype=1 then
begin
with MyIniFile do
begin
Password:=ReadString(Section, 'PassWord','000000');
userid:=ReadString(Section, 'USERID','000000');
DATASOURCE:=ReadString(Section, 'DATASOURCE','000000');
end; result:='Provider=MSDAORA.1;Password='+PASSWORD+
';User ID='+USERID+';Data Source='+
DATASOURCE+';Persist Security Info=True';
end
else begin
with MyIniFile do
begin
Password:=ReadString(Section, 'PassWord','000000');
userid:=ReadString(Section, 'USERID','000000');
DATASOURCE:=ReadString(Section, 'DATASOURCE','000000');
DEFAULTDB:= ReadString(Section, 'DATABASE','000000');
end;
result:='Provider=SQLOLEDB.1;Password='+PASSWORD+';Persist Security Info=True;User ID='+USERID+
';Initial Catalog='+DEFAULTDB+';Data Source='+DATASOURCE;
end;
MyIniFile.Free;
end;
//////////////////////unit中的声明及引出unit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;type
TForm1 = class(TForm)
Button1: TButton;
Memo1: TMemo;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
Function ReadDBinfo(section:string;databasetype:integer):string;
var
Form1: TForm1;implementation
function ReadDBinfo; external 'sms' index 4;
{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);
begin
memo1.Lines.Add(readdbinfo('Ora_48',1));
end;end.调用时出现错误,"Invalid pointer operation"
function ReadDbInfo(section:string;databasetype:integer):string;
var
MyIniFile: TIniFile;
PassWord,UserID,DataSource,Defaultdb,ss:string;
begin MyIniFile := TIniFile.Create('C:\CJSMS\DBINFO.ini');
if databasetype=1 then
begin
with MyIniFile do
begin
Password:=ReadString(Section, 'PassWord','000000');
userid:=ReadString(Section, 'USERID','000000');
DATASOURCE:=ReadString(Section, 'DATASOURCE','000000');
end; result:='Provider=MSDAORA.1;Password='+PASSWORD+
';User ID='+USERID+';Data Source='+
DATASOURCE+';Persist Security Info=True';
end
else begin
with MyIniFile do
begin
Password:=ReadString(Section, 'PassWord','000000');
userid:=ReadString(Section, 'USERID','000000');
DATASOURCE:=ReadString(Section, 'DATASOURCE','000000');
DEFAULTDB:= ReadString(Section, 'DATABASE','000000');
end;
result:='Provider=SQLOLEDB.1;Password='+PASSWORD+';Persist Security Info=True;User ID='+USERID+
';Initial Catalog='+DEFAULTDB+';Data Source='+DATASOURCE;
end;
MyIniFile.Free;
end;
//////////////////////unit中的声明及引出unit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;type
TForm1 = class(TForm)
Button1: TButton;
Memo1: TMemo;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
Function ReadDBinfo(section:string;databasetype:integer):string;
var
Form1: TForm1;implementation
function ReadDBinfo; external 'sms' index 4;
{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);
begin
memo1.Lines.Add(readdbinfo('Ora_48',1));
end;end.调用时出现错误,"Invalid pointer operation"
解决方案 »
- 请教关于TClientDataSet过滤的问题
- 在DELPHI中判断是否到了表的末尾
- 求助,发现一个Delphi 7的彩蛋, 不知道怎么重现
- 100分求教!!!delphi中adoconnection、storedprocedure和delphi中使用事务的问题!急!在线等!!!!!!!!!!
- ★★★★★第十三期:CSDN论坛秀-Delphi版-本期作秀:hongqi162(失踪的月亮)
- TreeView的简单问题
- 怎么和公司毁约?
- Treeview图标问题
- 请问怎样获得一个文件的扩展名?
- 称重软件及相关衡器行业系统集成及开发
- 关于IP
- 根据adoquery查询的数据库列数个数,显示Edit控件个数!!!!!!
就可
uses shareMem;
楼主,只要在调用的工程和dll的uses第一行加上ShareMem,再将borlandmm.dll放到工程文件夹下就搞定了。
program prjCallMyDLL;uses
ShareMem,
Forms,
untMain in 'untMain.pas' {Form1};{$R *.res}begin
Application.Initialize;
Application.CreateForm(TForm1, Form1);
Application.Run;
end.library MyDLL;{ 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,
Classes
Unit1 in 'Unit1.pas';{$R *.res}exports
ReadDbInfo;begin
end.