|
|
导航: |
论坛 -> DELPHI技术
斑竹:liumazi,sephil |
|
作者: |
sy0116 (sy0116) |
★☆☆☆☆ |
-
|
盒子活跃会员 |
|
2003/8/16 21:09:27 |
标题: |
如何用Delphi7运行DOS命令,这个代码怎么不行 |
浏览:2038 |
|
加入我的收藏 |
楼主: |
unit Unit1;
interface
uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs,shellapi, StdCtrls;
type TForm1 = class(TForm) Edit1: TEdit; Memo1: TMemo; Button1: TButton; procedure Button1Click(Sender: TObject); private { Private declarations } public { Public declarations } end;
var Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject); begin
ShellExecute(handle,'open','cmd.exe',' /k "dir edit1.text > c:\ao.txt"',',SW_HIDE);
Memo1.Lines.LoadFromFile('c:\ao.txt'); end;
end. 为什么有时提示错误找不到文件,而提示错误后再运行一次MEMO1就显示 驱动器D的卷是SOFT 卷的序列号是3F14-01C3 D:\Program Files\Borland\Delphi7\Projects 的目录
----------------------------------------------
- |
作者: |
root (root) |
★☆☆☆☆ |
-
|
普通会员 |
|
2003/8/17 11:26:09 |
1楼: |
edit1.text 不能放到字符串里面,要用 + Edit1.text + 的方法。
----------------------------------------------
-
|
作者: |
tp188 (tp188) |
★☆☆☆☆ |
-
|
普通会员 |
|
2003/8/20 9:55:47 |
2楼: |
同意楼上的,你上面那个是dir文件edit1.txt
----------------------------------------------
-
|
|