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还是一窍不通。但我会努力学习的!
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还是一窍不通。但我会努力学习的!
解决方案 »
- 请较CVS高手。
- 招聘高级Windows开发程序员
- 请教各位高手在delphi中用DCS如何发送数据
- 使用数据集table组件编写简单的桌面数据数,数据库使用dbf,库没有索引现在要在dbgrid中排序
- 我的SourceFormatX引来一个甚么赛迪网?小弟孤漏寡闻,请知道的兄弟赐教。
- 为什么老版本的帖子都没有了!
- 各位兄弟评理!小弟在一家公司实习差不多三月,实习前规定小弟只要做出一软件就可以把小弟转为正式员工!在此之前没工资!可小弟已经作好
- TWebBrowser无法全部获取网页源码..
- 谁有xml数据库有关的delphi源代码?----50分
- Delphi 线形太少,能否创建特出的线形,象地图中的铁路...
- 高手赐教
- 从BDE通过ADO连接access200,对数据库(Access)的更新操作出现了"[Microsoft][ODBC Microsoft Access Driver]非法的精确读数值"的提示?
但是在傳值要注意數據類型和大小寫
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'
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';
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'
function 函数名(参数列表):返回值类型;external'dll文件名';
以后你就可以调用其中的函数了,这是静态调用,如果找不到dll程序是不会向下执行的,还有动态调用的方法,你先试一下吧