如何传参数给EXE(100分)

  • 主题发起人 主题发起人 boyxu
  • 开始时间 开始时间
B

boyxu

Unregistered / Unconfirmed
GUEST, unregistred user!
各位大哥:<br>&nbsp; &nbsp; 如何传参数给EXE。当参数不对时,application.terminate。<br>&nbsp; &nbsp; 望能写出简单程序。
 
if (ParamCount&lt;&gt;x) or (ParamStr不对) then<br>&nbsp; Application.Terminate
 
用ParamStr<br>paramstr(0)是可执行文件的名字,paramstr(1)是第一个参数等.看Delphi的帮助<br><br>Returns a specified parameter from the command-line.<br><br>Unit<br><br>System<br><br>Category<br><br>command line utilities<br><br>function ParamStr(Index: Integer): string;<br><br>Description<br><br>ParamStr returns the parameter from the command line that corresponds to Index, or an empty string if Index is greater than ParamCount. For example, an Index value of 2 returns the second command-line parameter.<br><br>ParamStr(0) returns the path and file name of the executing program (for example, C:/TEST/MYPROG.EXE).<br><br>Note: Use double quotes to wrap multiple words as one parameter (such as long file names containing spaces)
 
后退
顶部