2009-12-09 9 views

Répondre

5

Delphi Prism (.Net) ne comprend pas la fonction ParamStr, mais peut être facilement mis en œuvre en utilisant la méthode GetCommandLineArgs, here est un exemple:

class method TMyClass.ParamStr(Index: Integer): String; 
var 
    MyAssembly: System.Reflection.Assembly; 
    Params : array of string; 
begin 
    if Index = 0 then 
    begin 
    MyAssembly:= System.Reflection.Assembly.GetEntryAssembly; 
    if Assigned(MyAssembly) then 
     Result := MyAssembly.Location 
    else 
     Result := System.Diagnostics.Process.GetCurrentProcess.MainModule.FileName; 
    end 
    else 
    begin 
    Params := System.Environment.GetCommandLineArgs; 
    if Index > Length(Params) - 1 then 
     Result := '' 
    else 
     Result := Params[Index]; 
    end; 
end; 

vous pouvez également voir le projet ShineOn qui comprend une mise en œuvre de la fonction ParamStr.