拨号Modem

  • 主题发起人 主题发起人 import
  • 开始时间 开始时间
I

import

Unregistered / Unconfirmed
GUEST, unregistred user!
来自:ahxia, 时间:01-8-24 13:26:00, ID:605771 刚刚做了一段东西,应该不是太难:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Edit_PhoneNumber: TEdit;
btnOpen: TButton;
btnClose: TButton;
Edit_CommPort: TEdit;
procedure btnOpenClick(Sender: TObject);
procedure btnCloseClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
hCommFile: THandle;
implementation
{$R *.dfm}
procedure TForm1.btnOpenClick(Sender: TObject);
var
i: DWORD;
PhoneNum: string;
begin
PhoneNum := 'ATDT'+Edit_PhoneNumber.Text + #13+#10;
hCommFile := CreateFile(PChar(Edit_CommPort.Text),
GENERIC_WRITE,
0,nil,
OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL,0);
if hCommFile = INVALID_HANDLE_VALUE then
begin
ShowMessage('Cannot open Port: '+Edit_CommPort.Text);
exit;
end;
i := 0;
if not WriteFile(hCommFile,
PChar(PhoneNum)^,
Length(PhoneNum),
i,
nil) then
begin
ShowMessage('Write Port error: '+Edit_CommPort.Text);
exit;
end;
end;
procedure TForm1.btnCloseClick(Sender: TObject);
begin
CloseHandle(hCommFile);
end;
end.
其实核心就是向 comm 口里写 atdt + 电话号
如果想挂断可以用 CloseHandle或者 ath0 ...
 

Similar threads

S
回复
0
查看
700
SUNSTONE的Delphi笔记
S
S
回复
0
查看
694
SUNSTONE的Delphi笔记
S
I
回复
0
查看
825
import
I
I
回复
0
查看
524
import
I
I
回复
0
查看
774
import
I
后退
顶部