{Platform:delphi7}procedure TForm1.buttom1Click(Sender: TObject);
type
TIntFunc = function(user_id:WideString;var errmsg:WideString):integer;stdcall;
var
Th:Thandle;
Tf:TIntFunc;
Tp:TFarProc;
str1,str2:String ;
begin
s1:=edit1.text;
Th:=LoadLibrary('C:\WINDOWS\system32\ftestdll.dll');
if Th>0 then
try
Tp:=GetProcAddress(Th,PChar('ftest'));
if Tp<>nil then
begin
try
Tf:=TIntFunc(Tp); Tf(str1,str1); finally
end; errmsgt.caption :=str2; end
else
ShowMessage('ftest¯ÊýûÓÐÕÒµ½');
finally
FreeLibrary(Th);
end
else
ShowMessage('ftestll.dllûÓÐÕÒµ½');
end;
现在错误信息如下:
[Error] test.pas(84): Types of actual and formal var parameters must be identical
[Fatal Error] apptest.dpr(6): Could not compile used unit 'test.pas'请教大虾,怎么回事?
try
@Tp:=GetProcAddress(Th,PChar('ftest'));
if @Tp <> nil then
begin
try
Tf(str1,str1);
...
----------------------------------------------------------
实参和形参的类型必须是一直的!