哪个可以给个调用外部dll文件的源码,第一次用--学习中

xxxfffcn 2004-05-05 03:19:11
哪个可以给个调用外部dll文件的源码,第一次用
...全文
47 4 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
xxxfffcn 2004-05-05
  • 打赏
  • 举报
回复
implementation

{$R *.dfm}

function GetDiskSER():string;stdcall;external 'F:\EIMS\stoff\1\diskser.dll';

procedure TForm1.Button1Click(Sender: TObject);
begin
showmessage(GetDiskSER());
end;

end.

上面运行进出错
在PB里可调用的
FUNCTION string GetDiskSER() LIBRARY "diskser.dll"
xxxfffcn 2004-05-05
  • 打赏
  • 举报
回复
这个分真的这么重要吗?
bqlhome 2004-05-05
  • 打赏
  • 举报
回复
老大,你也太小气了,问别人问题才给这么一点???
bqlhome 2004-05-05
  • 打赏
  • 举报
回复
这是DLL代码:


library AllPublic;

uses
Messages,
SysUtils,
Forms,
Classes,
Controls,
Dialogs,
Inifiles;

type
AFormInfo=array[0..4] of integer;

{$R *.res}

function GetNextId(Id: string): pchar;stdcall;
//=====Get a next number=================//
//=====Input value : starnumber =======//
//=====return value: Nextnumber =======//
//=====Write by : BaoQiongLin=======//
//=====Date : 2003/12/07 =======//
var
Int_len : Integer;
Int_pos : Integer;
Str_value: String ;
Int_char : Integer;
Next_flag : Boolean;
pos2 : Integer;
begin
Int_pos:=0;
pos2:=0;
Int_len:=Length(Id);
Str_value:=''; //return value
Next_flag:=true;
repeat
Int_char:=Ord(Id[Int_len-Int_pos]);
if Next_flag then
begin
Next_flag:=false;
Int_char:=Int_char+1;
If Int_char<48 then
begin
Int_char:=48;
end
else
begin
if Int_char>57 then
begin
Int_char:=48;
Next_flag:=true;
pos2:=pos2+1;
end;
end;
end;
Str_value:=chr(Int_char)+Str_value;
Int_pos:=Int_pos+1;
Until Int_pos>Int_len-1;
if Pos2=Int_pos then
Str_value:='A' + Str_value;
GetNextId:=Pchar(Str_value);
end;


exports
GetNextId,


begin

end.



下面是调用方法:

function GetNextId(Id: string): pchar;stdcall;
external 'AllPublic.dll';



然后在程序中加入

GetNextID(Str)即可


2,507

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 数据库相关
社区管理员
  • 数据库相关社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧