查看: 1203|回复: 7
|
Delphi7如何開啟其他程式
[复制链接]
|
|
如題
Delphi7如何開啟其他程式?
比如我想要開啟notepad, 共填上”1234”等字,要怎樣做呢?
謝謝 |
|
|
|
|
|
|
|
发表于 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 酱的吧... |
|
|
|
|
|
|
|

楼主 |
发表于 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; |
|
|
|
|
|
|
| |
本周最热论坛帖子
|