如何调用windows的拨号程序(100分)

  • 主题发起人 主题发起人 plwei
  • 开始时间 开始时间
P

plwei

Unregistered / Unconfirmed
GUEST, unregistred user!
我有两个问题:
1。如何设置一个Form ,使出现时不响应其它Form.即象只有一个确定按钮的
对话框一样。 我将Form 的BorderStyle设为bsDilog怎么不行。

2。如何在应用程序中调用'c:/windows/dialer.exe'下的电话拨号程序。
并将自己应用程序对话框中输入的号码自动加入到电话拨号程序中。
(我是在网上下载的一个小程序中看到的)

就这么多分了。请各位朋友相助。
 
这100分给我了 :)
程序已经发出!
 
2、用VB的OCX吧,好象叫 MS COMM之类的,也可以用超级通讯构件——
Ansy pro 什么都搞的定
 
你不会是在干'Hacker'的事吧!若这样做可是一事无成啊!
但要在后台干,则可能有效!?
 
1.设置fromstyle为fsstayontop,或在显示窗体时用showmodal
2.一般dialer.exe就在windows目录下,用winexec(pchar('dialer.exe'),
SW_SHOWNORMA),即可。至于加入电话号码,在执行完上面的程序后,直接发一个字符
串即可。在VB里有个sendkeys,delphi中应该也有类似函数。
 
dreamsoft请你告诉我, 在DELPHI中用什么样的函数snekeys呢?
 
我开始以为很简单,后来发现不那么容易,不过还是设法找到了答案。有关delphi中
实现sendkeys的全文如下:
The following example demonstrates procedures that provide the
capibility of sending keystrokes to any window control capable of
receiving keyboard input. You may use this technique to toggle
the num lock, caps lock, and scroll lock keys under Windows NT.

This same technique works for toggling caps lock and scroll lock
keys under Windows 95, but it will not work for num lock.
Note that there are four procedures provided: SimulateKeyDown(),
SimulateKeyUp(), SimulateKeystroke(), and SendKeys(), to allow greater
control in your ability to send keystrokes.

The SimulateKeyDown(), SimulateKeyUp(), and SimulateKeystroke()
procedures expect a virtural key code (like VK_F1).

The SimulateKeystroke() procedure accepts an extra parameter that is
useful when simulating the PrintScreen key. When extra is set to zero,
the entire screen will be captured to the windows clipboard. When
extra is set to one, only the active window will be captured.

The four button click methods demonstrate the use of these functions:
ButtonClick1 - Toggles the cap lock.
ButtonClick2 - Captures the entire screen to the clipboard.
ButtonClick3 - Capture the active window to the clipboard.
ButtonClick4 - Set the focus to an edit control and sends it a string.

Example:
procedure SimulateKeyDown(Key : byte);
begin
keybd_event(Key, 0, 0, 0);
end;

procedure SimulateKeyUp(Key : byte);
begin
keybd_event(Key, 0, KEYEVENTF_KEYUP, 0);
end;

procedure SimulateKeystroke(Key : byte;
extra : DWORD);
begin
keybd_event(Key,
extra,
0,
0);
keybd_event(Key,
extra,
KEYEVENTF_KEYUP,
0);
end;

procedure SendKeys(s : string);
var
i : integer;
flag : bool;
w : word;
begin
{Get the state of the caps lock key}
flag := not GetKeyState(VK_CAPITAL) and 1 = 0;
{If the caps lock key is on then turn it off}

if flag then
SimulateKeystroke(VK_CAPITAL, 0);
for i := 1 to Length(s) do begin
w := VkKeyScan(s);
{If there is not an error in the key translation}
if ((HiByte(w) <> $FF) and
(LoByte(w) <> $FF)) then begin
{If the key requires the shift key down - hold it down}
if HiByte(w) and 1 = 1 then
SimulateKeyDown(VK_SHIFT);
{Send the VK_KEY}
SimulateKeystroke(LoByte(w), 0);
{If the key required the shift key down - release it}
if HiByte(w) and 1 = 1 then
SimulateKeyUp(VK_SHIFT);
end;
end;
{if the caps lock key was on at start, turn it back on}
if flag then
SimulateKeystroke(VK_CAPITAL, 0);
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
{Toggle the cap lock}
SimulateKeystroke(VK_CAPITAL, 0);
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
{Capture the entire screen to the clipboard}
{by simulating pressing the PrintScreen key}
SimulateKeystroke(VK_SNAPSHOT, 0);
end;

procedure TForm1.Button3Click(Sender: TObject);
begin
{Capture the active window to the clipboard}
{by simulating pressing the PrintScreen key}
SimulateKeystroke(VK_SNAPSHOT, 1);
end;

procedure TForm1.Button4Click(Sender: TObject);
begin
{Set the focus to a window (edit control) and send it a string}
Application.ProcessMessages;
Edit1.SetFocus;
SendKeys('Dream Software Workshop');
end;

利用上面的函数,可以知道,在delphi下调用拨号程序dialer.exe的程序应该这样
写:
winexec(pchar('dialer.exe'),SW_SHOWNORMAL);
Application.ProcessMessages;
SimulateKeystroke(VK_RETURN, 0);
SendKeys('027-87547127');

我测试过,OK!
作了个示范程序给你,请接收。
 
dreamsoft 第一个问题将FORM设成fsstayontop 没有用还是能响应其它窗口。
 
在显示窗体时用showmodal,如下:
form2:=tform2.create(application);
form2.showmodal;
 
接受答案了.
 
后退
顶部