您当前的位置:delphi教程 > Delphi组件开发 > [求助]第一次编DLL文件,编译通过,但不能运行

[求助]第一次编DLL文件,编译通过,但不能运行

第一次编DLL文件,编译通过,但运行时出现如下提示:  
  access   violation   at   0x00000000   address:read   of   addresss   0x00000000.process  
  stoped.use   step   or   run   to   continue.  
   
   
  源程序如下,Project1.dll和调用工程Project12.dpr是放在同一目录下。  
   
   
  library   Project1;  
   
  uses  
      SysUtils,  
      Classes,  
      Unit1   in   'Unit1.pas';  
   
  exports  
      addexam;  
   
  {$R   *.res}  
   
  begin  
  end.  
   
   
  ////////////////////////////////////////////////////  
  unit   Unit1;  
  interface  
  function   addexam(a:integer;b:integer):integer;export;  
   
  implementation  
   
  function   addexam(a:integer;b:integer):integer;  
  var  
      c:integer;  
  begin  
      c:=a+b;  
      result:=c;  
  end;  
  end.  
   
  /////////////////////////////////////////////////////////////  
  unit   Unit12;  
   
  interface  
   
  uses  
      Windows,   Messages,   SysUtils,   Variants,   Classes,   Graphics,   Controls,   Forms,  
      Dialogs,   StdCtrls;  
   
  type  
      TForm1   =   class(TForm)  
          Label1:   TLabel;  
          Button1:   TButton;  
          procedure   Button1Click(Sender:   TObject);  
      private  
          {   Private   declarations   }  
      public  
          {   Public   declarations   }  
      end;  
   
  var  
      Form1:   TForm1;  
   
  function   addexam(a:integer;b:integer):integer;stdcall;external'Project1.dll';  
   
  implementation  
   
  {$R   *.dfm}  
   
  procedure   TForm1.Button1Click(Sender:   TObject);  
  var  
      d,e,f:integer;  
  begin  
      d:=1;  
      e:=3;  
      f:=addexam(d,e);  
      label1.Caption:=inttostr(f);  
  end;  
   
  end.  
   
 


查看回复
关于我们 | 网站地图 | 广告刊登 | 友情链接
Copyright ©2008 - 2010  Delphi2007.net  ,All Rights Reserved  粤ICP备09038647号
业务联系:allceoad#gmail.com QQ:20008835 最佳分辨率 1024×768