D4简单问题(20分)

B

boda.w

Unregistered / Unconfirmed
GUEST, unregistred user!
我在D4中不知道该用什么命令可以调用其他程序,D3中的executefile和
shellexecute命令都找不到!
 
Api用Winexec,但功能不强!
shellexecute是功能强大!说明如下:
这都是Api函数!
HINSTANCE ShellExecute(
HWND hwnd, // handle to parent window
LPCTSTR lpOperation, // pointer to string that specifies operation to perform
LPCTSTR lpFile, // pointer to filename or folder name string
LPCTSTR lpParameters, // pointer to string that specifies executable-file parameters
LPCTSTR lpDirectory, // pointer to string that specifies default directory
INT nShowCmd // whether file is shown when opened
);
 
添加一个库
uses shellAPI;
 
添加一个库
uses shellAPI;
你就能用shellexecute方法了,
 
刚想说,给你们抢先了。
举个例算了:
ShellExecute(nil,'open','Notepad.exe','c:/autoexec.bat',nil,sw_show);
如此便会运行记事本。
 
shellExecute 不但可以启动exe,还可以这么使:
ShellExecute(0, 'Open', 'c:/pic.bmp,'', '', SW_SHOWNORMAL);
ShellExecute(0, 'Open', 'c:/note.txt,'', '', SW_SHOWNORMAL);
etc.
这将调用与文件关联的程序打开文件
 
唉,来晚了,总共才 20 分,一分都抢不到了,就废话几句吧:
得确认系统建立了相应文件的关联才能使用,否则--没戏!
如果建立了对邮件的关联,你还可以:
ShellExecute(handle, Pchar('open'),
Pchar('mailto : wtiebo@linux.hdpu.edu.cn'),
Pchar(''), Pchar(''), SW_SHOWNORMAL);
 
唉,来晚了,总共才 20 分,一分都抢不到了,就废话几句吧:
得确认系统建立了相应文件的关联才能使用,否则--没戏!
如果建立了对邮件的关联,你还可以:
ShellExecute(handle, Pchar('open'),
Pchar('mailto : wtiebo@linux.hdpu.edu.cn'),
Pchar(''), Pchar(''), SW_SHOWNORMAL);
 
1 u could use winexec or shellexecute
2 uses the following file:
<delphi directory>/demo/doc/file...fmxutils.pas
i foget the current file path but i think u will find it or u could
use the file from d3 because it has source
good luck
 
真抱歉,前几天总是联不上网,今天好不容易才连上,这个问题该结束了.
感谢Seasky提供最正确的答案.
也感谢3h和patlovecl 的例子.
不过3h的例子
ShellExecute(nil,'open','Notepad.exe','c:/autoexec.bat',nil,sw_show);
不能运行通过,把第一个nil改为handle可运行通过.
请斑竹给Seasky加分.同时也感谢其他及时帮助我的朋友.
 
今天才联上网,很抱歉,拖了很久?
感谢Seasky提供最正确的答案.
也感谢3h和patlovecl 的例子.
不过3h的例子
ShellExecute(nil,'open','Notepad.exe','c:/autoexec.bat',nil,sw_show);
不能运行通过,把第一个nil改为handle可运行通过.
请斑竹给Seasky加分.同时也感谢其他及时帮助我的朋友.
 
顶部