用Delphi调用一个VC开发的DLL文件中遇到一个问题(50分)

  • 主题发起人 honghunter
  • 开始时间
H

honghunter

Unregistered / Unconfirmed
GUEST, unregistred user!
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'
大家帮帮忙看看,错在那里了啊?
我是Delphi初学者,目前基本上对Delphi还是一窍不通。但我会努力学习的!
 
有錯的地方很多。
'TForm1.FormCreate'前面有,後面卻刪了吧。inttostr應該是floattostr,
begin
和end數不一樣。參數LPCTSTR用了string,前面要用PAnsiChar修飾一下才行。
 
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: Pchar):DWORD;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 : String;
begin
fileName := 'uedit32.exe' ;
ProcID := GetProcByName(Pchar(fileName));
fileName := 'Inject.dll' ;
procResult := InjectDLL(ProcID,Pchar(fileName));
TForm1.Edit1.Text := FloatToStr(procResult);
end;
==================下面是报的错=========
Build
[Error] Unit1.pas(45): Incompatible types: 'String' and 'Cardinal'
[Error] Unit1.pas(47): Method identifier expected
[Error] Unit1.pas(47): There is no overloaded version of 'FloatToStr' that can be called with these arguments
[Error] Unit1.pas(55): Declaration expected but end of file found
[Fatal Error] Project1.dpr(5): Could not compile used unit 'Unit1.pas'

非常感谢springson的回答,但是我真的还是不知道怎么改啊?
能不能再说的具体一点啊?
 
要不你放在一個地方,我改好後再傳給你吧,有些是要看整個代碼才知道的。或全帖出來。
 
实在是不好意思

http://lotus.01www.net/forum/showtopic.asp?id=27&forumid=6&page=0
 
進去下不了。
 
在HIGHOT的http://bbs.highot.net/showthread.php?s=&threadid=117551
附件:http://bbs.highot.net/attachment.php?s=&postid=1279588
我的邮件cdc_hong@sina.com
要是还不行的话,希望能和你邮件联系。

 
好的,你發發來吧。springson@hotmail.com
 
下面的我改了下,可以檢測通過了。你郵件發過來的,也只是很多代碼中的一部分,很難調試。
procedure TForm1.Button1Click(Sender: TObject);
var
ProcID : DWORD;
procResult : DWORD;
//改動的地方String
fileName : String;
fileName1 : String;
begin
fileName := 'uedit32.exe' ;
ProcID := GetProcByName(Pchar(fileName));
fileName := 'Inject.dll' ;
procResult := InjectDLL(ProcID,PAnsichar(fileName));
Edit1.Text := FloatToStr(procResult);
//改動的地方
end;
 
顶部