请教,用 ShellExecute 执行 EXE 的时候,怎么样带命令参数啊?(50分)

  • 主题发起人 主题发起人 xinshouyige
  • 开始时间 开始时间
X

xinshouyige

Unregistered / Unconfirmed
GUEST, unregistred user!
用 ShellExecute 执行 EXE 的时候,怎么样带命令参数啊?比如:<br>要执行 "C:/ABC.exe -r -t"<br>用 ShellExecute 怎么执行?
 
ShellExecute(handle,nil,PChar('c:/abc.exe'),nil,nil,SW_SHOWNORMAL);这样就可以了。试试看……
 
ShellExecute(<br>&nbsp; &nbsp; &nbsp; hwmd, &nbsp; &nbsp; &nbsp;//父窗口句柄<br>&nbsp; &nbsp; &nbsp; LPCSTR lpszOp;//要执行操作窜的地址 可以为open ,print默认为open<br>&nbsp; &nbsp; &nbsp; LPCSTR lpszFile;//文件名窜的地址 <br>&nbsp; &nbsp; &nbsp; LPCSTR lpszParams;//执行文件串的地址<br>&nbsp; &nbsp; &nbsp; LPCSTR lpszDir;//默认目录串的地址<br>&nbsp; &nbsp; &nbsp; int fsShowCmd;//打开时文件是否显示<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; );<br>如果指定文件类型没有联系,和该文件类型中没有与操作的联系,返回31.<br>其他的具体返回之看help<br>
 
参见ShellApi.pas,<br>这是一份前人的文档<br>深入浅出ShellExecute <br><br>作者:徐景周<br><br><br><br>Q: 如何打开一个应用程序?<br><br>ShellExecute(this-&amp;gt;m_hWnd,"open","calc.exe","","", SW_SHOW );<br><br>或<br><br>ShellExecute(this-&amp;gt;m_hWnd,"open","notepad.exe",<br><br>"c:/MyLog.log","",SW_SHOW );<br><br><br><br><br><br>Q: 如何打开一个同系统程序相关连的文档?<br><br>ShellExecute(this-&amp;gt;m_hWnd,"open",<br><br>"c:/abc.txt","","",SW_SHOW );<br><br><br><br>Q: 如何打开一个网页?<br><br>ShellExecute(this-&amp;gt;m_hWnd,"open",<br><br>"http://www.google.com","","", SW_SHOW );<br><br><br><br>Q: 如何激活相关程序,发送EMAIL?<br><br>ShellExecute(this-&amp;gt;m_hWnd,"open",<br><br>"mailto:nishinapp@yahoo.com","","", SW_SHOW );<br><br><br><br>Q: 如何用系统打印机打印文档?<br><br>ShellExecute(this-&amp;gt;m_hWnd,"print",<br><br>"c:/abc.txt","","", SW_HIDE);<br><br><br><br>Q: 如何用系统查找功能来查找指定文件?<br><br>ShellExecute(m_hWnd,"find","d:/nish",<br><br>NULL,NULL,SW_SHOW);<br><br><br><br>Q: 如何启动一个程序,直到它运行结束?<br><br>SHELLEXECUTEINFO ShExecInfo = {0};<br><br>ShExecInfo.cbSize = sizeof(SHELLEXECUTEINFO);<br><br>ShExecInfo.fMask = SEE_MASK_NOCLOSEPROCESS;<br><br>ShExecInfo.hwnd = NULL;<br><br>ShExecInfo.lpVerb = NULL;<br><br>ShExecInfo.lpFile = "c:/MyProgram.exe"; <br><br>ShExecInfo.lpParameters = ""; <br><br>ShExecInfo.lpDirectory = NULL;<br><br>ShExecInfo.nShow = SW_SHOW;<br><br>ShExecInfo.hInstApp = NULL; <br><br>ShellExecuteEx(&amp;ShExecInfo);<br><br>WaitForSingleObject(ShExecInfo.hProcess,INFINITE);<br><br>或:<br><br>PROCESS_INFORMATION ProcessInfo; <br><br>STARTUPINFO StartupInfo; //入口参数<br><br>ZeroMemory(&amp;StartupInfo, sizeof(StartupInfo));<br><br>StartupInfo.cb = sizeof StartupInfo ; //分配大小<br><br>if(CreateProcess("c:/winnt/notepad.exe", NULL, <br><br>NULL,NULL,FALSE,0,NULL,<br><br>NULL,&amp;StartupInfo,&amp;ProcessInfo))<br><br>{ <br><br>WaitForSingleObject(ProcessInfo.hProcess,INFINITE);<br><br>CloseHandle(ProcessInfo.hThread);<br><br>CloseHandle(ProcessInfo.hProcess);<br><br>} <br><br>else<br><br>{<br><br>MessageBox("The process could not be started...");<br><br>}<br><br><br><br><br><br>Q: 如何显示文件或文件夹的属性?<br><br>SHELLEXECUTEINFO ShExecInfo ={0};<br><br>ShExecInfo.cbSize = sizeof(SHELLEXECUTEINFO);<br><br>ShExecInfo.fMask = SEE_MASK_INVOKEIDLIST ;<br><br>ShExecInfo.hwnd = NULL;<br><br>ShExecInfo.lpVerb = "properties";<br><br>ShExecInfo.lpFile = "c:/"; //也可以是文件<br><br>ShExecInfo.lpParameters = ""; <br><br>ShExecInfo.lpDirectory = NULL;<br><br>ShExecInfo.nShow = SW_SHOW;<br><br>ShExecInfo.hInstApp = NULL; <br><br>ShellExecuteEx(&amp;ShExecInfo);<br>
 
to fly_hong_924, archonwang,<br>&nbsp; 关键是命令行参数 -r -t !!!怎么带啊?
 
哦,第四个参数是命令参数。原来如比啊!谢谢
 

Similar threads

S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
2K
SUNSTONE的Delphi笔记
S
I
回复
0
查看
681
import
I
后退
顶部