Changeset 305 for Common/UCommon.pas


Ignore:
Timestamp:
Jan 3, 2012, 10:31:59 AM (13 years ago)
Author:
chronos
Message:
  • Added: Property Finished of TListedThread.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • Common/UCommon.pas

    r290 r305  
    6161procedure DeleteFiles(APath, AFileSpec: string);
    6262procedure OpenWebPage(URL: string);
     63procedure OpenFileInShell(FileName: string);
     64procedure ExecuteProgram(CommandLine: string);
    6365
    6466
     
    285287  L := MAX_USERNAME_LENGTH + 2;
    286288  SetLength(Result, L);
    287   if Windows.GetUserName(PChar(Result), L) and (L > 0) then
    288     SetLength(Result, StrLen(PChar(Result))) else
    289     Result := '';
     289  if Windows.GetUserName(PChar(Result), L) and (L > 0) then begin
     290    SetLength(Result, StrLen(PChar(Result)));
     291    Result := UTF8Encode(Result);
     292  end else Result := '';
    290293end;
    291294
     
    365368end;
    366369
     370procedure ExecuteProgram(CommandLine: string);
     371var
     372  Process: TProcess;
     373begin
     374  try
     375    Process := TProcess.Create(nil);
     376    Process.CommandLine := CommandLine;
     377    Process.Options := [poNoConsole];
     378    Process.Execute;
     379  finally
     380    Process.Free;
     381  end;
     382end;
     383
    367384procedure OpenWebPage(URL: string);
    368385var
     
    376393    //Process.Executable := Browser;
    377394    //Process.Parameters.Add(Format(Params, [ApplicationInfo.HomePage]);
    378     Process.Executable := 'cmd.exe';
    379     Process.Parameters.Add('/c');
    380     Process.Parameters.Add('start');
    381     Process.Parameters.Add(URL);
     395    Process.CommandLine := 'cmd.exe /c start ' + URL;
    382396    Process.Options := [poNoConsole];
    383397    Process.Execute;
     
    387401end;
    388402
     403procedure OpenFileInShell(FileName: string);
     404begin
     405  ExecuteProgram('cmd.exe /c start ' + FileName);
     406end;
    389407
    390408initialization
Note: See TracChangeset for help on using the changeset viewer.