ParamStr()这个函数是读取的Command Line里面的数据,我想知道他的读取原理,越深层次的越好。
希望讲的具体点。谢谢。分不够再加。
希望讲的具体点。谢谢。分不够再加。
解决方案 »
- ShowModal的问题
- 菜鸟问题:如何用BDE的table组件连接SQL数据库
- delphi如何调用window的folderBrowserDialog函数
- to 大侠们
- 高手进来说说怎么公用的变量和自定义函数放在程序中什么位置比较好!?如果用一个单独的文件呢又存行不行?程序中的其它模块怎样调用他们
- 如何直接拷贝文件到一个FTP地址?
- 平凡的数据库程序在其他机器上的使用问题!!
- delphi 6.0 中用ado控件如何实现多线程的数据表查询?
- 话务自动呼叫分配及排队机制的问题
- 谈谈你的ActiveForm编程的心得
- 新手问题,求助!!
- 如何把widestring类型用writefile写入再用readfile读出来?在线等,最好给个例子
就 for i:=1 to paramcount do s:=paramstr(i);
s就是获得的命令行参数http://lysoft.7u7.net
來實現的, 再進一步, 就要分析匯編了
function ParamStr(Index: Integer): string;
{$IFDEF MSWINDOWS}
var
P: PChar;
Buffer: array[0..260] of Char;
begin
Result := '';
if Index = 0 then
SetString(Result, Buffer, GetModuleFileName(0, Buffer, SizeOf(Buffer)))
else
begin
P := GetCommandLine;
while True do
begin
P := GetParamStr(P, Result);
if (Index = 0) or (Result = '') then Break;
Dec(Index);
end;
end;
{$ENDIF}
{$IFDEF LINUX}
begin
if Index < ArgCount then
Result := PCharArray(ArgValues^)[Index]
else
Result := '';
{$ENDIF}
end;
On Linux, ParamStr(0) returns the command used to execute the program, without parameters (for example, ./myprogram). This behavior is dependent on information returned by the shell program and may not be consistent among all shells.
Note: Use double quotes to wrap multiple words as one parameter (such as long file names containing spaces).