电脑爱好者,提供IT资讯信息及各类编程知识文章介绍,欢迎大家来本站学习电脑知识。 最近更新 | 联系我们 RSS订阅本站最新文章
电脑爱好者
站内搜索: 
当前位置:首页>> delphi技术>>关于exe文件传递参数方法:

关于exe文件传递参数方法

来源:远方网络 | 2006-1-7 | (有2111人读过)

关于exe文件传递参数方法

昨天同事问到,delphi里exe文件如何传递参数?
因为手头装了Delphi,PowerBuilder
以下就是代码:
Delphi:
以下内容为程序代码:

procedure TForm1.FormCreate(Sender: TObject);
var
i: Integer;
begin
for i:=1 to ParamCount do
begin
if LowerCase(ParamStr(i)) = 'beep' then
Application.MessageBox('Demo','beep',IDOK )
else if LowerCase(ParamStr(i))='exit' then
Application.Terminate;
end;
end;





PowerBuilder:
以下内容为程序代码:

string ls_cmd, ls_arg[]

integer i, li_argcnt

// Get the arguments and strip blanks
// from start and end of string
ls_cmd = Trim(CommandParm())

li_argcnt = 1
DO WHILE Len(ls_cmd) > 0

// Find the first blank
i = Pos( ls_cmd, " ")

// If no blanks (only one argument),
// set i to point to the hypothetical character
// after the end of the string
if i = 0 then i = Len(ls_cmd) + 1

// Assign the arg to the argument array.
// Number of chars copied is one less than the
// position of the space found with Pos
ls_arg[li_argcnt] = Left(ls_cmd, i - 1)

// Increment the argument count for the next loop
li_argcnt = li_argcnt + 1

// Remove the argument from the string
// so the next argument becomes first
ls_cmd = Replace(ls_cmd, 1, i, "")

LOOP




使用:
*.exe beep exit

=================================JoeCom 2004-11-20
delphi技术热门文章排行
网站赞助商
购买此位置

 

关于我们 | 网站地图 | 文档一览 | 友情链接| 联系我们

Copyright © 2003-2024 电脑爱好者 版权所有 备案号:鲁ICP备09059398号