ParamStr()这个函数是读取的Command Line里面的数据,我想知道他的读取原理,越深层次的越好。
希望讲的具体点。谢谢。分不够再加。

解决方案 »

  1.   

    看Help不好吗?
    就 for i:=1 to paramcount do s:=paramstr(i);
    s就是获得的命令行参数http://lysoft.7u7.net
      

  2.   

    就是用Windows Api: GetModuleFileName
    來實現的, 再進一步, 就要分析匯編了
      

  3.   

    Returns a specified parameter from the command-line.UnitSystemCategorycommand line utilitiesfunction ParamStr(Index: Integer): string;DescriptionParamStr 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.ParamStr(0) returns the path and file name of the executing program (for example, C:\TEST\MYPROG.EXE).Note: Use double quotes to wrap multiple words as one parameter (such as long file names containing spaces).
      

  4.   

    ParamStr的源码
    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;
      

  5.   

    DescriptionParamStr 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.On Windows, ParamStr(0) returns the path and file name of the executing program (for example, C:\TEST\MYPROG.EXE).
    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).
      

  6.   

    就是得到运行时的参数如appname -d:fdsafdsa