Hola..

Otro más...

unit MainFrm;

Código: Seleccionar todo

interface

uses
  Windows,
  XpMan,
  Forms,
  Controls,
  Classes,
  StdCtrls,
  ComCtrls,
  Graphics,
  ExtCtrls;

type
  TWinMain = class(TForm)
    StatusBar: TStatusBar;
    InfoLbl: TLabel;
    CopyBtn: TButton;
    Image1: TImage;
    procedure CopyBtnClick(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;


var
  WinMain: TWinMain;

implementation
{$R *.dfm}


procedure TWinMain.CopyBtnClick(Sender: TObject);
var
  Wow64DisableWow64FsRedirection: function(var OldValue: Pointer): BOOL; stdcall;
  Wow64RevertWow64FsRedirection: function(OldValue: Pointer): BOOL; stdcall;
  OldValue: Pointer;
begin
  try
    OldValue := nil;
    CopyFile(PChar('C:\Windows\System32\Notepad.exe'), PChar('C:\Test\Notepad32.exe'), TRUE);

    Wow64DisableWow64FsRedirection := GetProcAddress(GetModuleHandle(kernel32), 'Wow64DisableWow64FsRedirection');
    Wow64RevertWow64FsRedirection := GetProcAddress(GetModuleHandle(kernel32), 'Wow64RevertWow64FsRedirection');

    if Wow64DisableWow64FsRedirection(OldValue) then
    begin
      CopyFile(PChar('C:\Windows\System32\Notepad.exe'), PChar('C:\Test\Notepad64.exe'), TRUE);
      MessageBox(Handle, PChar('Wow64 file system redirection [Disabled sucessfully]'), PChar('INFORMATION'), MB_ICONINFORMATION);
    end
    else
    begin
      MessageBox(Handle, PChar('Unable to disable Wow64 file system redirection'), PChar('ERROR'), MB_ICONERROR);
      Exit;
    end;

    if Wow64RevertWow64FsRedirection(OldValue) then
      MessageBox(Handle, PChar('Wow64 file system redirection [Enabled sucessfully]'), PChar('INFORMATION'), MB_ICONINFORMATION)
    else
      MessageBox(Handle, PChar('Unable to Enable Wow64 file system redirection'), PChar('ERROR'), MB_ICONERROR);
  except
   (* nothing :) *)

  end;
end;
end. 
Espero que os sirva...

Saludos !!
Imagen


Solo lo mejor es suficiente...
Responder

Volver a “Fuentes”