//////////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"
解决方案 »
- ADOQuery和maskedit问题!
- TIdTcpServer 到底怎么获取待读缓冲去的大小,这个AThread.Connection.ReadFromStack(false,100,false);老是有异常。
- 请教DBExpress问题,请大虾看详情哦:
- 出奇简单。。。。。。。
- @@@@@@@@@@@@@@@@@@一个简单的问题◎◎◎◎◎◎◎◎◎◎◎
- ADOQuery增加数据,为什么保存后丢失?
- 怎样用sql语句给一个paradox数据表添加主键
- 谁用过动态建立数据库,然后访问之
- OP中有static变量吗,还有怎么接收命令行参数?
- DBEdit的问题?
- 关于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.