FileExists()返回false,即使文件存在 [英] FileExists() returns false, even if file exists

查看:418
本文介绍了FileExists()返回false,即使文件存在的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想检查System32目录(Windows 7)中是否存在dll。但是,即使存在,FileExists()也会返回false。 LoadLibrary返回有效的句柄。
在这种情况下,我只想检查文件是否存在并可视化此信息。
您是否有解决此问题的技巧?您有一台64位计算机,但是在32 Delphi进程中, Windows\system32 实际上重定向到 Windows\Syswow64 。因此,当您认为要在 Windows\system32 中存在文件时,系统实际上是在报告<$ c中文件的存在(或其他情况) $ c> Windows\Syswow64 。



如果确实需要查看真正的64位system32,则需要禁用文件重定向。您可以使用 Wow64DisableWow64FsRedirection() 函数。不要忘记使用 Wow64RevertWow64FsRedirection() 将其重新打开。请注意,禁用重定向器会产生广泛的影响,并可能导致非常奇怪的行为,因此请务必小心。


I want to check if a dll in System32 directory (Windows 7) exists. But even if it exists, FileExists() returns false. LoadLibrary returns a valid handle. In this case, I only want to check, if the files exists and visualize this information. Do you have a any tips to solve this?

解决方案

Most likely this is down to file redirection. You have a 64 bit machine but from the 32 Delphi process, Windows\system32 actually redirects to Windows\Syswow64. So when you think you are asking for the existence of a file in Windows\system32, the system is actually reporting the existance (or otherwise) of a file in Windows\Syswow64.

If you really do need to see into the true 64 bit system32 then you need to disable file redirection. You can do this with the Wow64DisableWow64FsRedirection() function. Don't forget to switch it back on with Wow64RevertWow64FsRedirection(). Beware that disabling the redirector has wide reaching effects and can result in very strange behaviour so do so with care.

这篇关于FileExists()返回false,即使文件存在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆