Delphi 中 paramstr 的用法

原型 function paramstr(i:index):string

对于任何application paramstr(0)都默认代表的是应用程序的绝对路径。那么有paramstr(0),就肯定

有paramstr(1),paramstr(2)...了。它们的值又是什么了?我试了下取出的是空值,又不能赋值。

delphi帮助中说Returns a specified parameter from the command-line.从命令行中返回一个特别的参数。

折腾了半天才搞清楚,就是在exe文件后面可以跟参数,paramstr 获取的就是exe文件后面跟参数。

如有可执行文件project1.exe 在运行中输入 e:\project1.exe 123 456 789

那么paramstr(1)='123' paramstr(2)='456' paramstr(3)='789'

用shellexecute的话可以在parameters参数位置输入值。不同的参数值之间用空格隔开

如 shellexecute(application.Handle,'open','project4.exe','123 456', 'e:\',SW_SHOW);

所以用paramstr可以在应用程序间进行数据传输。

转载至 http://apps.hi.baidu.com/share/detail/16669076 感谢原作者