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 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 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;