• Delphi32位程序拷贝system32目录中文件解决方法!


    源码下载:http://download.csdn.net/detail/sunylat/9740352

    unit Unit1;
    
    interface
    
    uses
      Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants,
      System.Classes, Vcl.Graphics,
      Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls;
    
    type
      TForm1 = class(TForm)
        Button1: TButton;
        procedure Button1Click(Sender: TObject);
      private
        { Private declarations }
    
        function DisableWowRedirection: Boolean;
    
        function RevertWowRedirection: Boolean;
      public
        { Public declarations }
      end;
    
    var
      Form1: TForm1;
    
    implementation
    
    {$R *.dfm}
    
    uses System.IOUtils;
    
    procedure TForm1.Button1Click(Sender: TObject);
    const
      sourceFile = 'c:windowssystem32cdedit.exe';
    var
      destFile: string;
    begin
      destFile := ExtractFilePath(paramstr(0)) + 'bcdedit.exe';
    
      try
        self.DisableWowRedirection;
    
        try
    
          if TFile.Exists(sourceFile) = true then
          begin
    
            self.Caption := '存在';
    
            TFile.Copy(sourceFile, destFile);
          end
          else
          begin
    
            self.Caption := '不存在';
          end;
    
        except
          on e: exception do
          begin
            showmessage(e.ToString);
          end;
    
        end;
    
      finally
        self.RevertWowRedirection;
      end;
    
    end;
    
    function TForm1.DisableWowRedirection: Boolean;
    type
      TWow64DisableWow64FsRedirection = function(var Wow64FsEnableRedirection
        : LongBool): LongBool; StdCall;
    var
      hHandle: THandle;
      Wow64DisableWow64FsRedirection: TWow64DisableWow64FsRedirection;
      isRedirect:LongBool;
    begin
      isRedirect := true;
      try
        hHandle := GetModuleHandle('kernel32.dll');
        @Wow64DisableWow64FsRedirection := GetProcAddress(hHandle,
          'Wow64DisableWow64FsRedirection');
        if ((hHandle <> 0) and (@Wow64DisableWow64FsRedirection <> nil)) then
          Wow64DisableWow64FsRedirection(isRedirect);
      except
        isRedirect := False;
      end;
    
      result:=isRedirect;
    end;
    
    function TForm1.RevertWowRedirection: Boolean;
    type
      TWow64RevertWow64FsRedirection = function(var Wow64RevertWow64FsRedirection
        : LongBool): LongBool; StdCall;
    var
      hHandle: THandle;
      Wow64RevertWow64FsRedirection: TWow64RevertWow64FsRedirection;
      isRedirect:LongBool;
    begin
      isRedirect := true;
      try
        hHandle := GetModuleHandle('kernel32.dll');
        @Wow64RevertWow64FsRedirection := GetProcAddress(hHandle,
          'Wow64RevertWow64FsRedirection');
        if ((hHandle <> 0) and (@Wow64RevertWow64FsRedirection <> nil)) then
          Wow64RevertWow64FsRedirection(isRedirect);
      except
        isRedirect := False;
      end;
    
      result:=isRedirect;
    end;
    
    end.

     参考文章:http://blog.csdn.net/gj333/article/details/8268379

  • 相关阅读:
    js监听全屏的事件
    java后端发送请求
    java参数转换为javaBean对象
    Cesiumjs初学第一天
    echarts设置toolTip大小和样式问题
    楼梯式导航
    SpringMybatisMapper
    ASP.NET Session丢失的情况
    C# 生成随机数
    c#实现每隔规定时间自动执行程序代码
  • 原文地址:https://www.cnblogs.com/sunylat/p/6295943.html
Copyright © 2020-2023  润新知