怎么写一个供调用的dll函数啊

micksxb 2005-05-10 07:00:56
一般的unit代码中是uses后面是type语句,type语句都是窗体中的组件的定义,我写的是dll,只是一个被调用的函数,也没有窗体,没有组件,type语句一个写些什么呢?
还有我写好的代码怎么有错误呢,好像系统根本不识别我写的东西,好像无法进入我写的函数似的呢?
这是我的代码,大家帮我看看百.
uses
ShareMem,
SysUtils,
Classes;

{$R *.res}

procedure SetPoint(x, y : Integer; s : PChar) StdCall; Exports SetPoint;

Var
tr : TRect;
DrawStyle: DWORD;
begin
DrawStyle := DrawStyle or DT_WORDBREAK or DT_EDITCONTROL
or DT_EXPANDTABS or DT_NOPREFIX;
tr.left := x;
tr.top := y;
//Windows.DrawText(Canvas.Handle,PChar(s),Length(s),tr,DrawStyle);
end;
...全文
76 4 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
lemon_wei 2005-05-11
  • 打赏
  • 举报
回复

/*-------仅供参考---------*/

library wei_soft;

{ 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}


{*** CRC位校验 ***
函数名: CRC
参 数: data 被校验的字符,
crcbuf 预设值
返回值:无
功 能:对16进制的某一位进行校验
注:本函数应由其它CRC 函数调用,不应该由程序员直接调用.

}
procedure CRC(data:byte;var crcbuf:word);stdcall;
var
i:integer;
last:byte;
begin
crcbuf:=crcbuf xor data;
for i:=1 to 8 do
begin
last:=crcbuf and $01;
crcbuf:= crcbuf shr 1;
if last=$01 then crcbuf:=crcbuf xor $A001 ;
end;
end;

{*** CRC校验函数 ***
函数名: CRCJiaoYan
参 数: a,b,c,d,e,f 被校验的6个字节位
返回值:无
功 能:对16进制数进行CRC校验
注:在intel芯片组中,得到的高位,低位是相反的。

}
Function CRCJiaoYan(const a,b,c,d,e,f:byte):word;stdcall;
var
crcbuf:word;
Num:array[0..5] of byte;
i:integer;
begin
crcbuf:=$ffff;
num[0]:=a;
num[1]:=b;
num[2]:=c;
num[3]:=d;
num[4]:=e;
num[5]:=f;
for i:=0 to 5 do
CRC(Num[i],crcbuf);
CRCJiaoYan:=crcbuf;
end;

exports
CRC,
CRCJiaoYan;
begin

end.

micksxb 2005-05-10
  • 打赏
  • 举报
回复
拜托天地良心,在下实在是找不到,要不劳驾您给帮著搜一个例子好么?
kanxue660 2005-05-10
  • 打赏
  • 举报
回复
自己查一下好了,网上都写的很详细了
Comer 2005-05-10
  • 打赏
  • 举报
回复
很多delphi书上都有现成的例子的。

在网上search一本电子书看看就行了

5,927

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 开发及应用
社区管理员
  • VCL组件开发及应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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