library filepb;
uses
SysUtils;{$R *.res}
function write(filename:pchar;text:pchar):integer;
var
h:cardinal;
len,i:integer;
label
final;
begin
result:=-1;
len:=length(text);
if fileexists(filename) then
begin
h:=fileopen(filename,fmopenreadwrite);
end
else
begin
h:=filecreate(filename);
end;
if h<0 then goto final;
fileseek(h,0,2);
result:=filewrite(h,text^,len)+filewrite(h,#13#10,2); final:
fileclose(h);end;
exports
write;end.
/////////////////////////////////////////////////////////
我用的“标准”数据类型。
被pb程序调用的时候,竟然出现非法操作经分析,不是pb的问题。因为同样的格式,调用windows api就好使。///////////////////////////
下面是pb里面的声明:1。调用findwindowa函数:function long FindWindowA(string a,string b) library "user32.dll";2。调用write函数:function long write(string a,string b) library "filepb.dll";////////////////////confused....
uses
SysUtils;{$R *.res}
function write(filename:pchar;text:pchar):integer;
var
h:cardinal;
len,i:integer;
label
final;
begin
result:=-1;
len:=length(text);
if fileexists(filename) then
begin
h:=fileopen(filename,fmopenreadwrite);
end
else
begin
h:=filecreate(filename);
end;
if h<0 then goto final;
fileseek(h,0,2);
result:=filewrite(h,text^,len)+filewrite(h,#13#10,2); final:
fileclose(h);end;
exports
write;end.
/////////////////////////////////////////////////////////
我用的“标准”数据类型。
被pb程序调用的时候,竟然出现非法操作经分析,不是pb的问题。因为同样的格式,调用windows api就好使。///////////////////////////
下面是pb里面的声明:1。调用findwindowa函数:function long FindWindowA(string a,string b) library "user32.dll";2。调用write函数:function long write(string a,string b) library "filepb.dll";////////////////////confused....
如果要在dll中输出函数一般用标准的stdcall的调用方式就没有问题了