链接文件。。。。到不存在的输出(100分)

L

later

Unregistered / Unconfirmed
GUEST, unregistred user!
想调用rasapi32.dll中的rashangup函数,编译时通过,运行时出错。错误为“链接文件
exp.exe到不存在的输出rasapi32.dll:rashanghup.”。
 
编译时没有检查DLL中是否存在你要调用函数。 运行时才去真正调用
如果不存在就报错了。 你DUMP一下RASAPI32.DLL 看看是否有这个函数存在
 
1.怎样dump?
2.我用vb可以正确调用rasapi32.dll中的hangup函数,说明RASAPI32.DLL 有这个函数存在。
 
RASAPI32.DLL 中 有RasHangUpW,RasHangUpA,没有 RasHangUp。
VB中你没看到别名吗?
建议这样写://参数我不知道,你自己添上。^-^!
{$IFDEF UNICODE}
function RasHangUp(...); external RASAPI32 name 'RasHangUpW';
{$ELSE}
function RasHangUp(...); external RASAPI32 name 'RasHangUpA';
{$ENDIF}

 
to JobsLee:
按你说的作,还是不行。我的程序如下:
unit exu1;

interface

uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;

type
rasconn95=record
dwsize:dword;
hrasconn:dword;
szentryname:array[0..255] of byte;
szdevicetype:array[0..15] of byte;
szdevicename:array[0..127] of byte;
end ;
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

function rasenumconnections(lprasconn:rasconn95;lpcb:dword;lpcconnection:dword):dword;
function rashangup(hrasconn:dword):dword;
var
Form1: TForm1;

implementation

{$R *.DFM}

function rasenumconnections;external'rasapi32.dll' ;
function rashangup;external'rasapi32.dll' name 'rashangupw';
procedure TForm1.Button1Click(Sender: TObject);
var
lngretcode:dword;
lpcb:dword;
lpcconnections:dword;
intarraysize:integer;
intindex:integer;
intlooper:integer;
lprasconn95:array[0..256] of rasconn95;

begin
lprasconn95[0].dwsize:=412;
lpcb:=256*lprasconn95[0].dwsize;
lngretcode:=rasenumconnections(lprasconn95[0],lpcb,lpcconnections);
if lngretcode=0 then
if lpcconnections>0 then
for intlooper:=0 to lpcconnections-1 do
begin
rashangup(lprasconn95[intlooper].hrasconn);
end
else
showmessage('no connection');
end;

end.
 
Api 区分大小写的。
按我给你的大小写形式来写。
 
use /delphi/bin/tdump.exe
useage tdump c:/winnt/system32/rasapi32.dll c:/rasapi32.txt
notepad c:/rasapi32.txt

输出结果:
Exports from RASAPI32.dll
144 exported name(s), 144 export addresse(s). Ordinal base is 1.
Sorted by Name:
RVA Ord. Hint Name
-------- ---- ---- ----
0000FB46 1 0000 DDMGetPhonebookInfo =>
0001C2AE 2 0001 DwCloneEntry =>
0001C4D2 3 0002 DwDeleteSubEntry =>
0001C3C1 4 0003 DwEnumEntriesForAllUsers =>
000013D4 5 0004 DwEnumEntryDetails =>
0001CBD4 6 0005 FreeSharedAccessApplication =>
0001CC0F 7 0006 FreeSharedAccessServer =>
0001D7DC 8 0007 RasAutoDialSharedConnection =>
0000EB39 9 0008 RasAutodialAddressToNetwork =>
0000E850 10 0009 RasAutodialEntryToNetwork =>
0000FF18 11 000A RasClearConnectionStatistics =>
0000FEA5 12 000B RasClearLinkStatistics =>
0000DCE2 13 000C RasConnectionNotificationA =>
 
顶部