执行程序调用
Mydll.MyProc(MyStream);DLL中
procedure myproc(aStream: TStream);
begin
aSTREAM.Size := 0; // 出错
// 后面我还有对aSTREAM的一些其他操作,很多方法都不是Tstream的virtual方法 end;
我想在DLL使用STREAM,有什么办法解决吗?
Mydll.MyProc(MyStream);DLL中
procedure myproc(aStream: TStream);
begin
aSTREAM.Size := 0; // 出错
// 后面我还有对aSTREAM的一些其他操作,很多方法都不是Tstream的virtual方法 end;
我想在DLL使用STREAM,有什么办法解决吗?
解决方案 »
- InterBase数据库新建视图找不到的问题(已经会了,来人回复一下我好结贴)
- 我下面的代码怎么执行不了?memo1里没有结果显示啊
- 在delphi程序中如何把中文已UTF-8编码?急!!
- 程序死机问题!
- 非托管代码缓冲区溢出问题 delphi8
- ??想在datagrid控件中加一列显示数据的序号,该怎样写??
- 怎么样做网络监视的程序???急~~~~~~~~~~~,15分呀,
- socet的问题
- 报表控件绑定数据表后为何只显示一条记录
- 谁有 Delphi 有关文件压缩的资料? dll,控件都行...
- adoquery参数为汉字,有时候有结果,有时候没有。。怎么办啊 。。在线等啊
- 怎样用delphi一次打开多个文件
另外流的大小不时随便赋值的,你写入了多少字节stream.size是自动计算的
另外如果要定位,使用stream.positon:=0
最好使用read方法读,write方法写
例如
Stream := TMemoryStream.Create;
TBlobField(qryTmp.FieldByName('c_grd_proText')).SaveToStream(Stream);
Stream.Position := 0;
Stream.Read(GridPro.storeInfo, Stream.size);
type
PStream = ^TStream;//2:重新定义导出函数量
procedure myproc(aStream: Pointer);export;
var
xx:PStream;
begin
xx:=aStream;
xx^.Size := 0; // 出错
// 后面我还有对aSTREAM的一些其他操作,很多方法都不是Tstream的virtual方法end;//3:调用说明
var
astream:TStream;
begin
astream:=TStream.Create;
try
myproc(@astream);
finally
astream.Free;
end;
end;
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;
procedure TestM(s: TStream); stdcall; external 'ProjDLL.dll';
implementation{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);
var
ms: TMemoryStream;
str: string;
begin
ms := TMemoryStream.Create;
TestM(ms);
SetLength(str, ms.size);
ms.Position := 0;
ms.Read(str[1], ms.Size);
FreeAndNil(ms);
ShowMessage(str);end;end.---------------------
library ProjDLL;{ 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}procedure TestM(s: TStream); stdcall; export;
var
str: string;
begin
str := FormatDateTime('YYYY-MM-DD HH:NN:SS.zzz', now);
s.Size := 0;
s.Write(str[1], length(str));
end;
exports TestM ;
begin
end.