Ver Mensaje Individual
  #18  
Antiguo 10-03-2020
Avatar de escafandra
[escafandra] escafandra is offline
Miembro Premium
 
Registrado: nov 2007
Posts: 2.197
Reputación: 20
escafandra Tiene un aura espectacularescafandra Tiene un aura espectacular
Es problema del unicode el delphi. Si se fuerza a usar AnsiChar funcionará. Este problema no ocurre en C, posiblemente esté mas declarada la API.
Prueba este código que si funciona en Berlin y funcionará en tu versión de delphi:


Código Delphi [-]
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ExtCtrls;

type
  TForm1 = class(TForm)
    Label1: TLabel;
    Timer1: TTimer;
    procedure FormCreate(Sender: TObject);
    procedure Timer1Timer(Sender: TObject);
  private
    function Execute(CommandLine: AnsiString): cardinal;
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

//------------------------------------------------------------------------------
// Creamos un proceso.
function TForm1.Execute(CommandLine: AnsiString): cardinal;
var
  SI: TStartupInfoA;
  PI: TProcessInformation;
begin
  ZeroMemory(@SI, sizeof(TStartupInfoA));
  SI.cb:= sizeof(SI);
  SI.dwFlags:= STARTF_USESHOWWINDOW or STARTF_USEPOSITION;
  SI.wShowWindow:= SW_SHOW;
  Result:= 0;
  if CreateProcessA(0, PAnsiChar(CommandLine), nil, nil, false, 0, nil, nil, SI, PI) then
  begin
    WaitForInputIdle(PI.hProcess, 10000);
    Visible:= false;
    WaitForSingleObject(PI.hProcess,INFINITE);
    GetExitCodeProcess(PI.hProcess, Result);
    CloseHandle(PI.hProcess);
    CloseHandle(PI.hThread);
  end
  else
    Result:= $FFFFFFFF;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  ShowWindow(Handle, SW_MAXIMIZE);
  WindowState:= wsMaximized;
  FormStyle:= fsStayOnTop;
  BorderStyle:= bsNone;
  Label1.Caption:= '"LOADING GAME"';
  Label1.Font.Size:= 30;
  Label1.Font.Style:= [fsBold];
  // Simula que tarda en cargar...
  Timer1.Interval:= 2000;
end;

procedure TForm1.Timer1Timer(Sender: TObject);
begin
  Timer1.Enabled:= false;
  // Simula que tarda en cargar...
  Execute('cmd.exe');
  Visible:= True;
  Label1.Caption:= 'NOS VAMOS';
  Update;
  Sleep(500);
  Close;
end;

end.

He añadido discretas mejoras y pasado a PAnsiChar.


Saludos.
Responder Con Cita