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:\windows\system32\bcdedit.exe';
var
destFile: string;
begin
destFile := ExtractFilePath(paramstr()) + '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 <> ) 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 <> ) and (@Wow64RevertWow64FsRedirection <> nil)) then
Wow64RevertWow64FsRedirection(isRedirect);
except
isRedirect := False;
end; result:=isRedirect;
end; end.
参考文章:http://blog.csdn.net/gj333/article/details/8268379
Delphi32位程序拷贝system32目录中文件解决方法!的更多相关文章
- 在Windows下通过命令行或者.bat文件统计一个目录中文件数量
在Windows下面怎样通过命令行统计一个目录中文件的数量,或者说,如果在一个.bat文件中,统计一个目录中的文件数量? 我原来以为是不可能的,要编一个vbs程序什么的,后来到网上找了下,发现还真是可 ...
- java统计指定目录中文件的个数和总的大小
转: 统计指定目录中文件的个数和总的大小 package file; import java.io.File; import java.util.ArrayList; public class Fil ...
- C#统计目录中文件MD5值
1. [代码]统计目录中文件MD5值 using System.IO;using System.Security.Cryptography;using System.Collections;using ...
- 使用java 程序创建格式为utf-8文件的方法(写入和读取json文件)
使用java 程序创建格式为utf-8文件的方法: try{ File file=new File("C:/11.jsp"); ...
- SQL Server 无法在服务器上访问指定的路径或文件解决方法
SQL Server 无法在服务器上访问指定的路径或文件解决方法 在SQL Server附加数据库或备份数据库时出现:无法在服务器上访问指定的路径或文件. 请确保您具有必需的安全权限且该路径或文件存在 ...
- vmware tools安装程序无法继续,Microsoft Runtime DLL安装程序未能完成安装。的解决方法
vmware tools安装程序无法继续,Microsoft Runtime DLL安装程序未能完成安装.的解决方法_华英雄_新浪博客 http://blog.sina.com.cn/s/blog_5 ...
- svn冲突文件解决方法
svn冲突文件解决方法 工具/原料 svn客户端 方法/步骤 1 通过SVN客户端更新需要的文件,如果出现有感叹号的文件,找到出现感叹号的文件. 2 选择感叹号文件,即冲突文件,单击鼠标右键对冲突文件 ...
- WAMP安装提示缺少 msvcr100.dll文件解决方法
WAMP安装提示缺少wamp msvcr100.dll文件解决方法 因为wamp基于vs c++2010开发,需要提前安装这个组件才可以正常运行 微软官方组件下载地址: 32位:http://www. ...
- 关于STM32运行时程序卡在B.处的解决方法
文章转载自:https://blog.csdn.net/u014470361/article/details/78780444 背景: 程序运行时,发现程序卡死在B.处. 解决方法: 程序卡死在B.处 ...
随机推荐
- Vertex Lit
[Vertex Lit] Vertex Lit path generally renders each object in one pass, with lighting from all light ...
- SaltStack 运行机理特点
SaltStack 运行机理特点 1.实时通讯(REAL-TIME COMMUNICATION) 所有 Salt minions 接收命令都是同时的,这意味着控制 10 个或者 10000 个系统所消 ...
- 71. Simplify Path (Stack)
Given an absolute path for a file (Unix-style), simplify it. For example, path = "/home/", ...
- vue和bootstrap的select控件貌似有冲突?
貌似vue和bootstrap的select控件会冲突,因为bootstrap的select控件会将option替换为<a>标签,这样就会导致vue渲染失败.(这个问题让我整了一个上午,最 ...
- 快速上手Runtime(二)之给分类添加属性
我们都知道,分类是不能直接添加属性的,那么我们有时候又需要实现这个功能,那么我们应该怎么办才能为分类添加上属性呢. Runtime给分类添加属性原理 给一个类声明属性,其实本质就是给这个类添加关联,并 ...
- 71. Simplify Path压缩文件的绝对路径
[抄题]: Given an absolute path for a file (Unix-style), simplify it. For example,path = "/home/&q ...
- SQL 数据库 学习 003 什么是数据库? 为什么需要数据库?是不是所有的软件都是用Sql Server?
什么是数据库? 为什么需要数据库? 是不是所有的软件都是用Sql Server? 我的电脑系统: Windows 10 64位 使用的SQL Server软件: SQL Server 2014 Exp ...
- tp5 $this/Db
- TF Boys (TensorFlow Boys ) 养成记(一):TensorFlow 基本操作
本资料是在Ubuntu14.0.4版本下进行,用来进行图像处理,所以只介绍关于图像处理部分的内容,并且默认TensorFlow已经配置好,如果没有配置好,请参考官方文档配置安装,推荐用pip安装.关于 ...
- 001 KNN分类 最邻近算法
1.文件5.0,3.5,1.6,0.6,apple5.1,3.8,1.9,0.4,apple4.8,3.0,1.4,0.3,apple5.1,3.8,1.6,0.2,apple4.6,3.2,1.4, ...