拨号程序的问题?(100分)

  • 主题发起人 主题发起人 nsj
  • 开始时间 开始时间
N

nsj

Unregistered / Unconfirmed
GUEST, unregistred user!
我所有的MODEM是无线通讯的,模块是SIEMENTS的MC35,用WINDOWS的建立拨号连接可以拨上服务器。
我现在想把拨号功能做在我的程序中,我试过用RASDIAL函数来拨号,总是返回错误信息:终止连接。
我的程序如下:
var
connect:RASDIALPARAMS;
r:dword;
dwresult:LPHRASCONN;
k:array[0..100] of char;
begin
fillchar(connect,sizeof(RASDIALPARAMS),0);
connect.dwSize:=sizeof(RASDIALPARAMS);
connect.szEntryName:='GPRS';
connect.szPhoneNumber:='*99***1#';
connect.szUserName:='';
connect.szPassword:='';
r:=rasdial(nil,'',@connect,0,nil,dwresult);
if r=0 then
showmessage('连接成功!')
else
begin
showmessage('连接失败!');
RasGetErrorString(r,k,1000);
memo1.Lines.Add(k);
end;
end;
不知哪里出错?
 
请看此贴:
http://www.delphibbs.com/delphibbs/dispq.asp?lid=532043
 
to Gusn:
你说的那种方法会调出WINDOWS的拨号框,而且要预先建立好拨号连接,我需要的是程序里自动拨号,而不会有界面的显示,拨号成功或失败返回一信息即可。
 
Undeclared identifier RASDIALPARAMS
请问要uses什么东东?
 
Undeclared identifier RASDIALPARAMS
说的是RASDIALPARAMS未定义,你需要自己定义一些数据结构及常数。很多,可在网上找到。
我用RasSetEntryProperties拨号总是报‘检测到一个不正确的结构大小’,怎么回事啊?
 
to hnzgf:麻烦你看看我下面这段代码有什么问题?

var
connect:tagRASENTRY;
r:dword;
dwresult:cardinal;
k:array[0..100] of char;
devicename: string;
begin
fillchar(connect,sizeof(tagRASENTRY),0);
connect.dwSize:=sizeof(tagRASENTRY);
with connect do
begin
dwfOptions := dwfOptions and (not RASEO_UseCountryAndAreaCodes);
dwfOptions := dwfOptions and (not RASEO_SpecificIpAddr);
dwfOptions := dwfOptions and (not RASEO_SpecificNameServers);
dwfOptions := dwfOptions and (not RASEO_IpHeaderCompression);
dwfOptions := dwfOptions and (not RASEO_RemoteDefaultGateway);
dwfOptions := dwfOptions and (not RASEO_DisableLcpExtensions);
dwfOptions := dwfOptions and (not RASEO_TerminalBeforeDial);
dwfOptions := dwfOptions and (not RASEO_TerminalAfterDial);
dwfOptions := dwfOptions and (not RASEO_ModemLights);
dwfOptions := dwfOptions and (not RASEO_SwCompression);
dwfOptions := dwfOptions and (not RASEO_RequireEncryptedPw);
dwfOptions := dwfOptions and (not RASEO_RequireMsEncryptedPw);
dwfOptions := dwfOptions and (not RASEO_RequireDataEncryption);
dwfOptions := dwfOptions and (not RASEO_NetworkLogon);
dwfOptions := dwfOptions and (not RASEO_UseLogonCredentials);
dwfOptions := dwfOptions and (not RASEO_PromoteAlternates);
dwfNetProtocols := dwfNetProtocols and (not RASNP_Ip);
dwfNetProtocols := dwfNetProtocols and (not RASNP_Netbeui);
dwfNetProtocols := dwfNetProtocols and (not RASNP_Ipx);
//dwfOptions:=RASEO_RequireMsEncryptedPw or RASEO_RequireDataEncryption;
dwFramingProtocol := 1;
StrPCopy(szScript, '');
//devicename :='';
StrPCopy(szLocalPhoneNumber, '*99***1#');
StrPCopy(szDeviceName, '');
StrPCopy(szDeviceType, RASDT_VPN);
end;
{if RasValidateEntryName(nil,'GPRSs')>0 then
showmessage('valid')
else
showmessage('not valid');}
r:=RasSetEntryProperties(nil,'',@connect,SizeOf(TRasEntry),nil,0);
if r=0 then
begin
ShowMessage('拨号网络连接创建成功.!');
end
else
begin
ShowMessage('拨号网络连接创建失败!');
showmessage(inttostr(r));
RasGetErrorString(r,k,100);
memo1.Lines.Add(k);
end;

总是报‘检测到一个不正确的结构大小’,为什么,谢谢。
 
后退
顶部