看来,我想用 FileExists() 检查的某些文件即使存在也永远找不到,而其他文件每次都会找到。
如果我将文件“driver.sys”放入“C:\Windows\System32\drivers\”目录中,则永远不会找到它(每次调用该函数时,FileExists 都是 false)。
如果我将文件移动到 Windows 根目录“C:\Windows\”,就会找到它。
这不起作用(虽然该文件肯定位于文件夹“C:\Windows\System32\drivers\”中):
function isNotDriverInstalled(): Boolean;
begin
if (FileExists('C:\Windows\System32\drivers\driver.sys')) then begin
Log('File exists');
Result := False;
end else begin
Log('File doesn''t exist');
Result := True;
end;
end;
这有效(当文件位于文件夹“C:\Windows\”中时):
function isNotDriverInstalled(): Boolean;
begin
if (FileExists('C:\Windows\driver.sys')) then begin
Log('File exists');
Result := False;
end else begin
Log('File doesn''t exist');
Result := True;
end;
end;
顺便说一句:我使用的是 Windows 7,64 位。
以前有人经历过这样的案例吗?
有什么建议么?
提前谢谢!
Your System32
目录被映射到SysNative
路径由于File System Redirector http://msdn.microsoft.com/en-us/library/windows/desktop/aa384187%28v=vs.85%29.aspx,正如您所看到的,对此类目录路径进行硬编码并不那么容易。最好使用下面列出的内置常量之一:
1. {sys} 常量:
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)