电话拨号

I

import

Unregistered / Unconfirmed
GUEST, unregistred user!
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 下 TYPE。。。end 之外}
lpszEntryName(pchar):要修改的拨号连接的名称,如‘163’,‘169’等。
函数返回值:0表示成功,否则为错误。
例:PROcedure TForm1.button2click(Sender:TObject);
如上。
3.获取当前系统中可用的拨号连接名称.。
在建立了拨号连接后,WIN9X将拨号连接的名称和属性写了注册表中,我们可以从注册表中可用的拨号连接名称
及InterNet Explorer中的默认连接名称。
在注册表的HKEY_USERS.DEFAULT下,列出了已经在拨号网络中建立的拨号连接
的名称及其属性设置,其中各项目的名称即为可用的拨号连接的名称;各项目的值即为各连接的属性设置.
如果在InterNet Explorer 中设置了默认连接名称(Internet 选项=>>连接=>>设置=>>使用以下拨号网络连接)
则在注册表的HKEY_USERS.Default下,有一个字符串类型的键值,键值名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
if OpenKey('.Default',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',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 Explicit
Private 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 Sub
Private Sub cmdExit_Click()
Unload Me
End Sub
Private Sub Form_Load()
Move (Screen.Width - Width) 2, (Screen.Height - Height) 2
EnableDial
End Sub
Private Sub txtNumber_Change()
EnableDial
End Sub
Private Sub EnableDial()
cmdDial.Enabled = Len(Trim$(txtNumber)) > 0
End Sub
Tapi的拨号功能和通话工能是最强的,但也比较繁。
不过如果只是拨号,那么用tapiRequestMakeCall()是非常方便的!
当然,如过要进行更复杂的组合拨号和电话控制就要涉及更复杂的tapi函数,如lineMakCall()
lineDial()和消息处理
详见msdn
 

Similar threads

I
回复
0
查看
652
import
I
I
回复
0
查看
600
import
I
I
回复
0
查看
520
import
I
顶部