昨天在技术群里讨论的时候谈到,如何显示一个对话框,选择一个任意程序,然后任意这个程序。
自已一开始的思路是用SHELL选择,然后用SHELLEXECUTE API函数执行,这样实现。
于是,自己开始试。
在试的过程中,发现SHELL只能具体到文件夹级别,而要确定文件,还是要用通用对话框,MICROSOFT COMMON DIALOG。而VFP的一个内置函数GETFILE()即可完成,于是又退出来,后来,一经探索,两个步骤成了两种方案,怎么走都能实现。
现总结如下:
方案一,用API函数实现。
代码如下:
DECLARE integer shellexecute IN shell32.dll as shellexecutea integer hWnd,string strOpration,string lpFile,string ;lpdirectory,integer showCmdDeclare integer OpenPrinter in winspool.drv String,Long,long
LOCAL file2Run
file2Run=GETFILE()
shellexecute(0,0,file2Run,0,0,1)
方案二,用SHELL实现(前面仍用GETFILE()函数或得路径)
LOCAL file2Run
LOCAL wshShell
file2Run=GETFILE()
wshShell=CREATEOBJECT("shell.application")
wshShell.shellexecute(file2Run)
Trackback: http://tb.donews.net/TrackBack.aspx?PostId=46774