1。创建新的拨号连接。
参数:
hwn PROCEDURE TForm1.button1click(Sender:TObject);
VAR dwhandle:word;
aaa:integer;
begin
aaa:=getactivewindow();
dwResult:=RasCreatePhonebookEntryA(handle,'');
或DWresult:=RasCreatePhonebookEntryA(aaa,'');
if dwResult=0 then
memo1.lines.add('新建拨号连接成功!')
ELSE
memo1.lines.add('新建拨号连接失败!') end;
2.修改指定拨号连接的属性。
Function RasEditPhonebookEntryA(hwnd:Thandle;lpszPhonebook:pchar;lpszEntryName:pchar):Dword;
stdcall; {位于Interface的USES 下 TYPEend 之外}
lpszEntryName(pchar):要修改的拨号连接的名称,如‘163’,‘169’等。
函数返回值:0表示成功,否则为错误。
例:PROcedure TForm1.button2click(Sender:TObject);
如上。
3.获取当前系统中可用的拨号连接名称.。
在建立了拨号连接后,WIN9X将拨号连接的名称和属性写了注册表中,我们可以从注册表中可用的拨号连接名称
及InterNet Explorer中的默认连接名称。
在注册表的HKEY_USERS\.DEFAULT\RemoteACess\Address下,列出了已经在拨号网络中建立的拨号连接
的名称及其属性设置,其中各项目的名称即为可用的拨号连接的名称;各项目的值即为各连接的属性设置.
如果在InterNet Explorer 中设置了默认连接名称(Internet 选项=>>连接=>>设置=>>使用以下拨号网络连接)
则在注册表的HKEY_USERS\.Default\RemoteAcess下,有一个字符串类型的键值,键值名InternetProfile,其值
即为Internet Explorer中设置的默认连接名称.
{在Uses中增加Registry单元,用于操作注册表}
procedure TForm1.button3click(Sender:TObject);
var
registrytemp:TRegistry;
stringtemp:TStringlist;
intindex:integer;
begin
registrytemp:=TRegistry.Create;
stringTemp:=Tstringlist.Create;
with registryTemp DO
BEGIN
RootKey:=HKEY_USERS; //根键置为HKEY_USERS
//如果存在于子键.Default\RemoteAccess\Addresses
if OpenKey('.Default\RemoteAccess\Addresses',false) then
getValueNames(stringsTemp); //读出各项目的名称,即拨号连接名称
closekey;
end;
memo1.lines.add( '************当前系统中有'+IntTostr(stringsTemp.count)'
+'各可用的拨号连接如下******');
for intindex:=0 to stringsTemp.count-1 do
memo1.lines.add(stringstemp.strings[intindex]); //列出Internet explorer中默认连接名称.
if registrytemp.Openkey('.Default\RemoteAccess\Addresses',false') then
mome1.lines.add('Internet explorer中默认连接名称为'+Registry.readstring('InternetProfile'));
//释放内存
RegistryTemp.free;
StringsTemp.free;
end;
4.用指定的拨号连接拨号
winexec('rundll32.exe rnaui.dll,RnaDial 163',SW_SHOWNORMAL);
其中字符串中的最后一个参数'163'为拨号连接的名称.
Procedure TForm1.botton4click(Sender:TObject);
var
strDiaName:string;
begin
strDiaName:='163';
memo1.lines.add('*****用拨号连接'+strDiaName+'实现拨号上网******');
winexec('rundll32.exe rnaui.dll,RnaDial 163',SW_SHOWNORMAL);
end;
end;用以下API函数:(代码为VB)
'AutoDial是一个使用Tapi函数拨号的范例
'
Option ExplicitPrivate Declare Function tapiRequestMakeCall& Lib "TAPI32.DLL" (ByVal DestAddress$, ByVal AppName$, ByVal CalledParty$, ByVal Comment$)
Private Const TAPIERR_NOREQUESTRECIPIENT = -2&
Private Const TAPIERR_REQUESTQUEUEFULL = -3&
Private Const TAPIERR_INVALDESTADDRESS = -4&
Private Sub cmdDial_Click()
Dim buff As String
Dim nResult As Long
‘在此拨号
nResult = tapiRequestMakeCall&(Trim$(txtNumber), CStr(Caption), "Test Dial", "")
If nResult <> 0 Then
buff = "Error dialing number : "
Select Case nResult
Case TAPIERR_NOREQUESTRECIPIENT
buff = buff & "No Windows Telephony dialing application is running and none could be started."
Case TAPIERR_REQUESTQUEUEFULL
buff = buff & "The queue of pending Windows Telephony dialing requests is full."
Case TAPIERR_INVALDESTADDRESS
buff = buff & "The phone number is not valid." Case Else
buff = buff & "Unknown error."
End Select
MsgBox buff
End If
End SubPrivate Sub cmdExit_Click()
Unload Me
End SubPrivate Sub Form_Load()
Move (Screen.Width - Width) \ 2, (Screen.Height - Height) \ 2
EnableDial
End SubPrivate Sub txtNumber_Change()
EnableDial
End SubPrivate Sub EnableDial()
cmdDial.Enabled = Len(Trim$(txtNumber)) > 0
End Sub
参数:
hwn PROCEDURE TForm1.button1click(Sender:TObject);
VAR dwhandle:word;
aaa:integer;
begin
aaa:=getactivewindow();
dwResult:=RasCreatePhonebookEntryA(handle,'');
或DWresult:=RasCreatePhonebookEntryA(aaa,'');
if dwResult=0 then
memo1.lines.add('新建拨号连接成功!')
ELSE
memo1.lines.add('新建拨号连接失败!') end;
2.修改指定拨号连接的属性。
Function RasEditPhonebookEntryA(hwnd:Thandle;lpszPhonebook:pchar;lpszEntryName:pchar):Dword;
stdcall; {位于Interface的USES 下 TYPEend 之外}
lpszEntryName(pchar):要修改的拨号连接的名称,如‘163’,‘169’等。
函数返回值:0表示成功,否则为错误。
例:PROcedure TForm1.button2click(Sender:TObject);
如上。
3.获取当前系统中可用的拨号连接名称.。
在建立了拨号连接后,WIN9X将拨号连接的名称和属性写了注册表中,我们可以从注册表中可用的拨号连接名称
及InterNet Explorer中的默认连接名称。
在注册表的HKEY_USERS\.DEFAULT\RemoteACess\Address下,列出了已经在拨号网络中建立的拨号连接
的名称及其属性设置,其中各项目的名称即为可用的拨号连接的名称;各项目的值即为各连接的属性设置.
如果在InterNet Explorer 中设置了默认连接名称(Internet 选项=>>连接=>>设置=>>使用以下拨号网络连接)
则在注册表的HKEY_USERS\.Default\RemoteAcess下,有一个字符串类型的键值,键值名InternetProfile,其值
即为Internet Explorer中设置的默认连接名称.
{在Uses中增加Registry单元,用于操作注册表}
procedure TForm1.button3click(Sender:TObject);
var
registrytemp:TRegistry;
stringtemp:TStringlist;
intindex:integer;
begin
registrytemp:=TRegistry.Create;
stringTemp:=Tstringlist.Create;
with registryTemp DO
BEGIN
RootKey:=HKEY_USERS; //根键置为HKEY_USERS
//如果存在于子键.Default\RemoteAccess\Addresses
if OpenKey('.Default\RemoteAccess\Addresses',false) then
getValueNames(stringsTemp); //读出各项目的名称,即拨号连接名称
closekey;
end;
memo1.lines.add( '************当前系统中有'+IntTostr(stringsTemp.count)'
+'各可用的拨号连接如下******');
for intindex:=0 to stringsTemp.count-1 do
memo1.lines.add(stringstemp.strings[intindex]); //列出Internet explorer中默认连接名称.
if registrytemp.Openkey('.Default\RemoteAccess\Addresses',false') then
mome1.lines.add('Internet explorer中默认连接名称为'+Registry.readstring('InternetProfile'));
//释放内存
RegistryTemp.free;
StringsTemp.free;
end;
4.用指定的拨号连接拨号
winexec('rundll32.exe rnaui.dll,RnaDial 163',SW_SHOWNORMAL);
其中字符串中的最后一个参数'163'为拨号连接的名称.
Procedure TForm1.botton4click(Sender:TObject);
var
strDiaName:string;
begin
strDiaName:='163';
memo1.lines.add('*****用拨号连接'+strDiaName+'实现拨号上网******');
winexec('rundll32.exe rnaui.dll,RnaDial 163',SW_SHOWNORMAL);
end;
end;用以下API函数:(代码为VB)
'AutoDial是一个使用Tapi函数拨号的范例
'
Option ExplicitPrivate Declare Function tapiRequestMakeCall& Lib "TAPI32.DLL" (ByVal DestAddress$, ByVal AppName$, ByVal CalledParty$, ByVal Comment$)
Private Const TAPIERR_NOREQUESTRECIPIENT = -2&
Private Const TAPIERR_REQUESTQUEUEFULL = -3&
Private Const TAPIERR_INVALDESTADDRESS = -4&
Private Sub cmdDial_Click()
Dim buff As String
Dim nResult As Long
‘在此拨号
nResult = tapiRequestMakeCall&(Trim$(txtNumber), CStr(Caption), "Test Dial", "")
If nResult <> 0 Then
buff = "Error dialing number : "
Select Case nResult
Case TAPIERR_NOREQUESTRECIPIENT
buff = buff & "No Windows Telephony dialing application is running and none could be started."
Case TAPIERR_REQUESTQUEUEFULL
buff = buff & "The queue of pending Windows Telephony dialing requests is full."
Case TAPIERR_INVALDESTADDRESS
buff = buff & "The phone number is not valid." Case Else
buff = buff & "Unknown error."
End Select
MsgBox buff
End If
End SubPrivate Sub cmdExit_Click()
Unload Me
End SubPrivate Sub Form_Load()
Move (Screen.Width - Width) \ 2, (Screen.Height - Height) \ 2
EnableDial
End SubPrivate Sub txtNumber_Change()
EnableDial
End SubPrivate Sub EnableDial()
cmdDial.Enabled = Len(Trim$(txtNumber)) > 0
End Sub
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货