佳礼资讯网

 找回密码
 注册

ADVERTISEMENT

查看: 1203|回复: 7

Delphi7如何開啟其他程式

[复制链接]
发表于 13-11-2006 12:17 AM | 显示全部楼层 |阅读模式
如題

Delphi7如何開啟其他程式?

比如我想要開啟notepad, 共填上”1234”等字,要怎樣做呢?

謝謝
回复

使用道具 举报


ADVERTISEMENT

发表于 15-11-2006 12:56 PM | 显示全部楼层
原帖由 eefui 于 13-11-2006 12:17 AM 发表
如題

Delphi7如何開啟其他程式?

比如我想要開啟notepad, 共填上”1234”等字,要怎樣做呢?

謝謝


先create file, 写了你要的内容,再用 shellexecute(). 可以参考help file. shellexecute 有几个override method...


uses ShellApi;
...
ShellExecute(Handle, 'open', 'c:\Windows\notepad.exe', nil, nil, SW_SHOWNORMAL) ; Open SomeText.txt with Notepad


ShellExecute(Handle,'open', 'c:\windows\notepad.exe','c:\SomeText.txt', nil, SW_SHOWNORMAL) ; Display the contents of the "DelphiDownload" folder


ShellExecute(Handle,'open', 'c:\DelphiDownload', nil, nil, SW_SHOWNORMAL) ; Execute a file according to its extension.


ShellExecute(Handle, 'open', 'c:\MyDocuments\Letter.doc',nil,nil,SW_SHOWNORMAL) ;

或参考
http://delphi.about.com/od/windowsshellapi/a/executeprogram.htm

[ 本帖最后由 kennynjc 于 15-11-2006 12:58 PM 编辑 ]
回复

使用道具 举报

 楼主| 发表于 16-11-2006 05:25 AM | 显示全部楼层
謝謝 kennynjc 兄

己經可以了

如果我想在己經開啟的notepad填上一些文字,如填上abc等文字,要如何做呢?

又或者我開了calculator,想用mouse控制,click  1 + 1 =  ,是否可以做到呢?

謝謝
回复

使用道具 举报

发表于 16-11-2006 12:56 PM | 显示全部楼层

回复 #3 eefui 的帖子

NotePad 的话还可以,calculator 呢就...重点在为什么要那么做??
回复

使用道具 举报

 楼主| 发表于 16-11-2006 07:04 PM | 显示全部楼层
我想做一個會自動install program的程式,比如會自動打serial number,會自動click "next" 等等. 不知難度會不會很高?
回复

使用道具 举报

发表于 16-11-2006 07:33 PM | 显示全部楼层

回复 #5 eefui 的帖子

没什么概念, 都是要写script的,准备好installer, 然后用dos command to run. 你想要做的大概是像wise installation system 酱的吧...
回复

使用道具 举报

Follow Us
 楼主| 发表于 17-11-2006 07:56 AM | 显示全部楼层
不知道用SendMessage可以做到嗎??

你講如果只是在notepad寫東西就可以做到,不知如何做呢??
回复

使用道具 举报

发表于 17-11-2006 01:16 PM | 显示全部楼层

回复 #7 eefui 的帖子

procedure TFMain.Button1Click(Sender: TObject);
var
  F : TextFile;
begin
  //shellExecute(handle,'open','c:\windows\notepad.exe','c:\a.txt',nil,SW_SHOWNORMAL);
  AssignFile(F, 'c:\a.txt');
  Reset(F);
  Rewrite(F);
  Writeln(F,'AAA');
  CloseFile(F);
  shellExecute(handle,'open','c:\windows\notepad.exe','c:\a.txt',nil,SW_SHOWNORMAL);
end;



procedure TFMain.Button2Click(Sender: TObject);
var
  F : TextFile;
begin
  AssignFile(F, 'c:\a.txt');
  Reset(F);
  Append(F);
  //Rewrite(F);
  Writeln(F,'CCC');
  CloseFile(F);

  showmessage('append done');
end;
回复

使用道具 举报


ADVERTISEMENT

您需要登录后才可以回帖 登录 | 注册

本版积分规则

 

ADVERTISEMENT



ADVERTISEMENT



ADVERTISEMENT

ADVERTISEMENT


版权所有 © 1996-2023 Cari Internet Sdn Bhd (483575-W)|IPSERVERONE 提供云主机|广告刊登|关于我们|私隐权|免控|投诉|联络|脸书|佳礼资讯网

GMT+8, 23-8-2025 05:41 AM , Processed in 0.134335 second(s), 24 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表