怎么样通过一个按钮的点击实现命令行操作的命令?(30分)

  • 主题发起人 主题发起人 liuyang
  • 开始时间 开始时间
L

liuyang

Unregistered / Unconfirmed
GUEST, unregistred user!
在2000下,开始--&gt;运行--&gt;敲"CMD"--&gt;在黑色屏幕下敲<br>"net send aa bbbb" 就可以给AA这台机子发消息BBBB.<br>我想通过DELPHI做个程序点击按钮实现?机器名和消息是可以输入的.<br>我写了一个但不知道怎么的没有反应?请各位帮忙看一看了:)<br>unit Unit1;<br><br>interface<br><br>uses<br>&nbsp; Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,<br>&nbsp; StdCtrls,shellapi;<br><br>type<br>&nbsp; TForm1 = class(TForm)<br>&nbsp; &nbsp; Button1: TButton;<br>&nbsp; &nbsp; procedure Button1Click(Sender: TObject);<br>&nbsp; private<br>&nbsp; &nbsp; { Private declarations }<br>&nbsp; public<br>&nbsp; &nbsp; { Public declarations }<br>&nbsp; &nbsp; procedure URLink(URL:PChar);<br>&nbsp; end;<br><br>var<br>&nbsp; Form1: TForm1;<br><br>implementation<br><br>{$R *.DFM}<br><br>procedure tform1.URLink(URL:PChar);<br>begin<br>ShellExecute(0, nil, URL, nil, nil, SW_NORMAL);<br>end;<br><br><br><br><br>procedure TForm1.Button1Click(Sender: TObject);<br>begin<br>&nbsp; &nbsp; URLink('c:/winnt/system32/net.exe send &nbsp;aa bbbb');<br>end;<br><br>end.<br><br>
 
procedure TForm1.Button1Click(Sender: TObject);<br>var BatFile:Textfile;<br>begin<br>&nbsp; assignfile(BatFile,'SendMsg.bat');<br>&nbsp; rewrite(BatFile);<br>&nbsp; writeln(BatFile,'net send aa bbb');{这里可以任意组合}<br>&nbsp; closefile(BatFile);<br>&nbsp; winexec('SendMsg.bat',SW_NORMAL);<br>end;<br>
 
接受答案了.
 
后退
顶部