Z
zhangkan
Unregistered / Unconfirmed
GUEST, unregistred user!
我调用我自己写的一个极简单的DLL例子,但调用出问题,不知是什么问题。源代码如下:
library fvsystem;//专案档
uses
SysUtils,
Classes,
FVUnit in 'FVUnit.pas';
{$R *.RES}
exports
TurnExcelCell index 1 name 'TurnExcelCell';
begin
end.
//程序档
unit FVUnit;
interface
uses
Windows,Messages,Sysutils,Dialogs;
function TurnExcelCell(a, k: integer): string;export;
implementation
function TurnExcelCell(a, k: integer): string;
var x,y,z:string;
b,c,i,j:integer;
begin
i:=0;
j:=0;
b:=a div 26;
c:=a mod 26;
if (b>=27) and (c>0) then begin
ShowMessage('轉換EXCEL行列值超出范圍﹗');
abort;
end
else if (b>0) and (b=27) then
i:=64+b-1
else if (b>0) and (b<27) then
i:=64+b
else if b=0 then
i:=64+26;
if c>0 then
j:=64+c
else if c=0 then
j:=64+26;
x:=Chr(i);
y:=Chr(j);
if (b>0) and (c>0) then
z:=x+y
else if (c=0) and (b=27) then
z:=x+y
else if ((c=0) and (b>0)) or ((c>0) and (b=0)) then
z:=y
else
z:=x;
Result:=z+IntToStr(k);
end;
end.
生成DLL正常,调用过程中出问题
unit libdll; //unit
interface
uses windows;
function TurnExcelCell(a, k: integer): string;
implementation
function TurnExcelCell(a, k: integer): string;external 'fvsystem.dll';
end.
//调用
procedure TForm1.Button1Click(Sender: TObject);
var tempstr:string;
begin
tempstr:=TurnExcelCell(1,2);
showmessage(tempstr);
end;
能正常得出结果,但接着出现“invalid pointer operation”的错误提示,不知是为什么。
哪位大侠能告诉我为什么吗?另外,有否关于写DLL的资料能告诉我,谢谢。我对此知道得
太少了。
library fvsystem;//专案档
uses
SysUtils,
Classes,
FVUnit in 'FVUnit.pas';
{$R *.RES}
exports
TurnExcelCell index 1 name 'TurnExcelCell';
begin
end.
//程序档
unit FVUnit;
interface
uses
Windows,Messages,Sysutils,Dialogs;
function TurnExcelCell(a, k: integer): string;export;
implementation
function TurnExcelCell(a, k: integer): string;
var x,y,z:string;
b,c,i,j:integer;
begin
i:=0;
j:=0;
b:=a div 26;
c:=a mod 26;
if (b>=27) and (c>0) then begin
ShowMessage('轉換EXCEL行列值超出范圍﹗');
abort;
end
else if (b>0) and (b=27) then
i:=64+b-1
else if (b>0) and (b<27) then
i:=64+b
else if b=0 then
i:=64+26;
if c>0 then
j:=64+c
else if c=0 then
j:=64+26;
x:=Chr(i);
y:=Chr(j);
if (b>0) and (c>0) then
z:=x+y
else if (c=0) and (b=27) then
z:=x+y
else if ((c=0) and (b>0)) or ((c>0) and (b=0)) then
z:=y
else
z:=x;
Result:=z+IntToStr(k);
end;
end.
生成DLL正常,调用过程中出问题
unit libdll; //unit
interface
uses windows;
function TurnExcelCell(a, k: integer): string;
implementation
function TurnExcelCell(a, k: integer): string;external 'fvsystem.dll';
end.
//调用
procedure TForm1.Button1Click(Sender: TObject);
var tempstr:string;
begin
tempstr:=TurnExcelCell(1,2);
showmessage(tempstr);
end;
能正常得出结果,但接着出现“invalid pointer operation”的错误提示,不知是为什么。
哪位大侠能告诉我为什么吗?另外,有否关于写DLL的资料能告诉我,谢谢。我对此知道得
太少了。