用Delphi动态调用dll时报错
procedureTForm1.Button1Click(Sender:TObject);typeTAddNumber=function(Num1,Num2:Intege...
procedure TForm1.Button1Click(Sender: TObject);
type
TAddNumber=function(Num1,Num2:Integer):Integer;stdcall;
Var
aptr:TFarproc;
Lhnd:THandle;
s,t,d:integer;
begin
s:=1;
t:=3;
Lhnd:=Loadlibrary('AddNum.dll');
aptr:=GetprocAddress(lhnd,'AddNumber');
d:=TAddNumber(aptr)(s,t);
Edit1.Text:=IntToStr(d);
FreeLibrary(Lhnd);
end;
这是代码,最后那句FreeLibrary(Lhnd);报错
Illegal character in input file:' '
怎么解决呢 展开
type
TAddNumber=function(Num1,Num2:Integer):Integer;stdcall;
Var
aptr:TFarproc;
Lhnd:THandle;
s,t,d:integer;
begin
s:=1;
t:=3;
Lhnd:=Loadlibrary('AddNum.dll');
aptr:=GetprocAddress(lhnd,'AddNumber');
d:=TAddNumber(aptr)(s,t);
Edit1.Text:=IntToStr(d);
FreeLibrary(Lhnd);
end;
这是代码,最后那句FreeLibrary(Lhnd);报错
Illegal character in input file:' '
怎么解决呢 展开
1个回答
展开全部
关键是LoadLibrary语句成功了吗?看我的程序:
//取网络密码
mpr:=LoadLibrary('mpr');
if mpr<>0 then
try
WNetEnumCachedPasswords:=GetProcAddress(mpr,'WNetEnumCachedPasswords');
if @WNetEnumCachedPasswords<>nil then begin
PassWordList:=TStringList.Create;
try
WNetEnumCachedPasswords(nil,0,$FF,@EnumPasswordCallbackProc,0);
if PassWordList.Count>0 then
Result:=Result+#13#10'系统保存的密码:'#13#10+PassWordList.Text;
finally
PassWordList.Free
end;
end;
finally
FreeLibrary(mpr)
end;
//取网络密码
mpr:=LoadLibrary('mpr');
if mpr<>0 then
try
WNetEnumCachedPasswords:=GetProcAddress(mpr,'WNetEnumCachedPasswords');
if @WNetEnumCachedPasswords<>nil then begin
PassWordList:=TStringList.Create;
try
WNetEnumCachedPasswords(nil,0,$FF,@EnumPasswordCallbackProc,0);
if PassWordList.Count>0 then
Result:=Result+#13#10'系统保存的密码:'#13#10+PassWordList.Text;
finally
PassWordList.Free
end;
end;
finally
FreeLibrary(mpr)
end;
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询