一般的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;

解决方案 »

  1.   

    很多delphi书上都有现成的例子的。在网上search一本电子书看看就行了
      

  2.   


    /*-------仅供参考---------*/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;
    beginend.