CSDN首页 空间 新闻 论坛 Blog 下载 读书 网摘 搜索 .NET Java 视频 接项目 求职 在线学习 买书 程序员 通知
山寨机中的战斗机! 程序优化工程师到底对IT界有没有贡献
CSDN社区
搜索 收藏 打印 关闭
CSDN社区 >  Delphi >  VCL组件开发及应用

用Delphi调用一个VC开发的DLL文件

楼主honghunter(龙江黑虎)2003-11-01 11:49:43 在 Delphi / VCL组件开发及应用 提问

VC开发的DLL中:  
  extern   DLLEXPORT   int   WINAPI   InjectDLL(DWORD   ProcID,   LPCTSTR   dll);  
   
   
  我在Delphi中,是不是这样宣告啊?  
   
  implementation  
  {$R   *.dfm}  
  (*   begin   呼叫   Inject.DLL   export   函数的宣告   *)  
  function   InjectDLL(ProcID:   DWORD;   dll:   LPCTSTR):   intfar;   external   'Inject.DLL';  
  (*int   WINAPI   (DWORD   ProcID,   LPCTSTR   dll);*)  
  (*   end   呼叫   Inject.DLL   export   函数的宣告   *)  
  end.  
   
   
  我是Delphi初学者,目前基本上对Delphi还是一窍不通。但我会努力学习的! 问题点数:20、回复次数:7Top

1 楼chenkandy(多少爱可以重来)回复于 2003-11-01 11:53:45 得分 5

function     InjectDLL(DWORD   ProcID,   LPCTSTR   dll);stdcall;external   'Inject.DLL';  
  但是在傳值要注意數據類型和大小寫Top

2 楼honghunter(龙江黑虎)回复于 2003-11-01 13:03:17 得分 0

unit   Unit1;  
   
  interface  
   
  uses  
      Windows,   Messages,   SysUtils,   Variants,   Classes,   Graphics,   Controls,   Forms,  
      Dialogs,   StdCtrls;  
   
  type  
      TForm1   =   class(TForm)  
          Button1:   TButton;  
          Edit1:   TEdit;  
          procedure   Button1Click(Sender:   TObject);  
      private  
          {   Private   declarations   }  
      public  
          {   Public   declarations   }  
      end;  
   
  var  
      Form1:   TForm1;  
   
  implementation  
   
  {$R   *.dfm}  
   
   
  (*   begin   呼叫   Inject.DLL   export   函数的宣告   *)  
  function   InjectDLL(ProcID:   DWORD;   dll:   LPCTSTR):   intfar;   external   'Inject.DLL';  
  function     InjectDLL(DWORD   ProcID,   LPCTSTR   dll);stdcall;external   'Inject.DLL';  
  function     GetProcByName(char   *   name);stdcall;external   'Inject.DLL';  
  (*   end   呼叫   Inject.DLL   export   函数的宣告   *)  
   
  procedure   TForm1.Button1Click(Sender:   TObject);  
   
  var  
      ProcID   :   dword;  
      procResult   :   int;  
   
  begin  
   
      ProcID   :=   GetProcByName("uedit32.exe");  
   
      procResult   :=   InjectDLL(ProcID,"Inject.dll");  
   
      TForm1.Edit1.text   :=   inttostr(procResult)  
   
   
  end;  
   
  ===================下面是报的错==========  
  Build  
      [Error]   Unit1.pas(29):   Undeclared   identifier:   'intfar'  
      [Error]   Unit1.pas(30):   Missing   parameter   type  
      [Error]   Unit1.pas(30):   Missing   parameter   type  
      [Error]   Unit1.pas(31):   Missing   parameter   type  
      [Error]   Unit1.pas(38):   '('   expected   but   ';'   found  
      [Error]   Unit1.pas(42):   Illegal   character   in   input   file:   '"'   ($22)  
      [Error]   Unit1.pas(42):   Illegal   character   in   input   file:   '"'   ($22)  
      [Error]   Unit1.pas(44):   Illegal   character   in   input   file:   '"'   ($22)  
      [Error]   Unit1.pas(44):   Illegal   character   in   input   file:   '"'   ($22)  
      [Error]   Unit1.pas(55):   Declaration   expected   but   end   of   file   found  
      [Fatal   Error]   Project1.dpr(5):   Could   not   compile   used   unit   'F:\Delphi开发\Unit1.pas'  
  Top

3 楼aiirii(ari-http://spaces.msn.com/members/aiirii/)回复于 2003-11-01 13:14:45 得分 5

(*   begin   呼叫   Inject.DLL   export   函数的宣告   *)  
  function   InjectDLL(ProcID:   DWORD;   dll:   LPCTSTR):   intfar;   external   'Inject.DLL';  
  function     InjectDLL(DWORD   ProcID,   LPCTSTR   dll);stdcall;external   'Inject.DLL';  
  function     GetProcByName(char   *   name);stdcall;external   'Inject.DLL';  
  (*   end   呼叫   Inject.DLL   export   函数的宣告   *)  
   
  修改如下:  
  function     InjectDLL(ProcID:   DWORD;dll:   Pchar);stdcall;external   'Inject.DLL';  
   
  Top

4 楼honghunter(龙江黑虎)回复于 2003-11-01 15:37:23 得分 0

unit   Unit1;  
   
  interface  
   
  uses  
      Windows,   Messages,   SysUtils,   Variants,   Classes,   Graphics,   Controls,   Forms,  
      Dialogs,   StdCtrls;  
   
  type  
      TForm1   =   class(TForm)  
          Button1:   TButton;  
          Edit1:   TEdit;  
          procedure   Button1Click(Sender:   TObject);  
          procedure   FormCreate(Sender:   TObject);  
      private  
          {   Private   declarations   }  
      public  
          {   Public   declarations   }  
      end;  
   
  var  
      Form1:   TForm1;  
   
  implementation  
   
  {$R   *.dfm}  
   
   
  (*   begin   呼叫   Inject.DLL   export   函数的宣告   *)  
  function     InjectDLL(ProcID:   DWORD;dll:   LPCTSTR):DWORD;stdcall;external   'Inject.DLL';  
  //function     GetProcByName(char   *   name);stdcall;external   'Inject.DLL';  
  function     GetProcByName(char:   Pchar):DWORD;stdcall;external   'Inject.DLL';  
  (*   end   呼叫   Inject.DLL   export   函数的宣告   *)  
   
  procedure   TForm1.Button1Click(Sender:   TObject);  
   
  var  
      ProcID   :   dword;  
      procResult   :   String;  
      fileName   :   String;  
      fileName1   :   LPCTSTR;  
   
  begin  
      fileName   :=   'uedit32.exe'   ;  
      ProcID   :=   GetProcByName(Pchar(fileName));  
   
      fileName1   :=   'Inject.dll'   ;  
      procResult   :=   InjectDLL(ProcID,fileName);  
   
      TForm1.Edit1.text   :=   inttostr(procResult)  
   
   
  end;  
   
  end;  
   
  ==================下面是报的错=========  
   
  Build  
      [Error]   Unit1.pas(48):   Incompatible   types:   'String'   and   'PAnsiChar'  
      [Error]   Unit1.pas(50):   Method   identifier   expected  
      [Error]   Unit1.pas(50):   There   is   no   overloaded   version   of   'IntToStr'   that   can   be   called   with   these   arguments  
      [Error]   Unit1.pas(55):   '.'   expected   but   ';'   found  
      [Error]   Unit1.pas(14):   Unsatisfied   forward   or   external   declaration:   'TForm1.FormCreate'  
      [Fatal   Error]   Project1.dpr(5):   Could   not   compile   used   unit   'Unit1.pas'  
  Top

5 楼honghunter(龙江黑虎)回复于 2003-11-02 15:19:35 得分 0

大家帮帮忙看看,错在那里了啊?  
  Top

6 楼lianshaohua(永远深爱一个叫“...”的好女孩儿!)回复于 2003-11-02 21:51:50 得分 10

不是呀,是这样:  
  function   函数名(参数列表):返回值类型;external'dll文件名';  
  以后你就可以调用其中的函数了,这是静态调用,如果找不到dll程序是不会向下执行的,还有动态调用的方法,你先试一下吧Top

7 楼honghunter(龙江黑虎)回复于 2003-11-04 19:58:06 得分 0

谢谢你的提醒,我再试试。Top

相关问题

  • delphi调用Vc Dll问题?
  • 关于VC写dll给delphi调用的!!
  • Delphi编的DLL能被VC++调用吗?
  • VC调用Delphi编制的DLL问题
  • VC中如何调用Delphi的dll?
  • Delphi 如何调用 VC 编写的 DLL?
  • Delphi调用VC++编写的Dll问题
  • Delphi调用VC++编写的Dll问题
  • VC写的DLL,Delphi中如何调用?
  • delphi动态调用vc dll的问题

关键词

  • 函数
  • delphi
  • dll
  • procid
  • injectdll
  • inject
  • procresult
  • 呼叫
  • lpctstr
  • tform

得分解答快速导航

  • 帖主:honghunter
  • chenkandy
  • aiirii
  • lianshaohua

相关链接

  • Delphi类图书
  • Delphi类源码下载
  • Delphi控件下载

广告也精彩

反馈

请通过下述方式给我们反馈
反馈
提问
网站简介|广告服务|VIP资费标准|银行汇款帐号|网站地图|帮助|联系方式|诚聘英才|English|问题报告
北京创新乐知广告有限公司 版权所有, 京 ICP 证 070598 号
世纪乐知(北京)网络技术有限公司 提供技术支持
Copyright © 2000-2008, CSDN.NET, All Rights Reserved
GongshangLogo