Ver Mensaje Individual
  #10  
Antiguo 28-06-2024
darkamerico darkamerico is offline
Miembro
 
Registrado: dic 2010
Posts: 273
Reputación: 16
darkamerico Va por buen camino
Red face modificaciones a tu codigo

Amigo hice algunas cosas en tu codigo:

Código Delphi [-]

function EsWindows64Bits: Boolean;
type
  TIsWow64Process = function(Handle: THandle; var Res: BOOL): BOOL; stdcall;
var
  IsWow64Result: BOOL;
  IsWow64Process: TIsWow64Process;
begin
  Result := False;
  IsWow64Process := GetProcAddress(GetModuleHandle('kernel32.dll'), 'IsWow64Process');
  if Assigned(IsWow64Process) then
  begin
    if IsWow64Process(GetCurrentProcess, IsWow64Result) then
    begin
      Result := IsWow64Result;
    end;
  end;
end;

procedure TfrmPrincipal.Button1Click(Sender: TObject);
var
  rutaSistema, rutaFileLocal, Destino:string;
  FO:TSHFileOpStruct;
  lbTerminar:Boolean;
begin
  rutaFileLocal:=ExtractFilePath(Application.ExeName);
  if EsWindows64Bits then
  begin // Si Windows es de 64 bits copio y pego las dos DLL en System 32
    rutaSistema:='C:\Windows\SysWOW64\';

    if not FileExists(rutaSistema + 'WebView2Loader_x64.dll') then
    begin
      Destino := 'C:\Windows\SysWOW64';

      ZeroMemory(@FO, SizeOf(FO));
      FO.Wnd := 0;
      FO.wFunc := FO_COPY;
      FO.pFrom := PChar(rutaFileLocal+'Files\WebView2Loader_x64.dll' + #0);
      FO.pTo := PChar(Destino + #0);
      FO.fFlags := FOF_NOCONFIRMATION or FOF_NOCONFIRMMKDIR;

      if SHFileOperation(FO) <> 0 then
        Application.MessageBox(PChar('Hubo un error con WebView2Loader_x64.dll'), PChar('OK'),MB_OK + MB_ICONERROR)
      else
        lbTerminar:=True;
    end;
  end
  else // 32 Bits
  begin
    rutaSistema:='C:\Windows\System32\';

    if not FileExists(rutaSistema+'WebView2Loader_x86.dll') then
    begin
      Destino := 'C:\Windows\System32';

      ZeroMemory(@FO, SizeOf(FO));
      FO.Wnd := 0;
      FO.wFunc := FO_COPY;
      FO.pFrom := PChar(rutaFileLocal+'Files\WebView2Loader_x86.dll' + #0);
      FO.pTo := PChar(Destino + #0);
      FO.fFlags := FOF_NOCONFIRMATION or FOF_NOCONFIRMMKDIR;

      if SHFileOperation(FO) <> 0 then
        Application.MessageBox(PChar('Hubo un error con WebView2Loader_x86.dll'), PChar('Ok'),MB_OK + MB_ICONERROR)
      else
        lbTerminar:= true;
     end;
  end;
end;

Última edición por darkamerico fecha: 28-06-2024 a las 17:20:06.
Responder Con Cita