如何得到shell传递的参数?

tdcqupt 2003-04-17 01:27:06
就是c中的
int argc;
char *argv[];

急问!
...全文
60 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
ccrun.com 2003-04-17
  • 打赏
  • 举报
回复
同意使用ParamStr(i);
ljianq 2003-04-17
  • 打赏
  • 举报
回复
在CB中的例子:
he following example beeps once for each 揵eep?passed in on the command line. The example terminates the application if 揺xit?is passed in on the command line.

void __fastcall TForm1::FormCreate(TObject *Sender)

{
for (int i=1;i<=ParamCount();i++)
{
if (LowerCase(ParamStr(i)) == "beep")
Beep(10000,1000);
elseif (LowerCase(ParamStr(i)) == "exit")
Application->Terminate();
}
}

在Windows的API;
The GetCommandLine function returns a pointer to the command-line string for the current process.

LPTSTR GetCommandLine(VOID)


Parameters

This function has no parameters.

Return Values

The return value is a pointer to the command-line string for the current process.

Remarks

Non-Unicode console processes written in C can use the argc and argv arguments to access the command-line arguments. The parameters of the command-line string, excluding the program name, are also available to such non-Unicode applications as a parameter of the WinMain function. The reason for the Unicode exclusion from these options is that WinMain, argc, and argv use the
LPSTR data type for parameters, not the LPTSTR datatype.

13,825

社区成员

发帖
与我相关
我的任务
社区描述
C++ Builder相关内容讨论区
社区管理员
  • 基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧