FindNextFile fails on 64-bit Windows?

谁说我不能喝 提交于 2019-12-05 00:44:50

Is there redirection going on? See the remarks on Wow64DisableWow64FsRedirection http://msdn.microsoft.com/en-gb/library/aa365743.aspx

I found this on MSDN:

If you are writing a 32-bit application to list all the files in a directory and the application may be run on a 64-bit computer, you should call the Wow64DisableWow64FsRedirectionfunction before calling FindFirstFile and call Wow64RevertWow64FsRedirection after the last call to FindNextFile. For more information, see File System Redirector.

Here's the link

I'll have to update my code because of this :-)

Got it:

http://msdn.microsoft.com/en-gb/library/aa384187(VS.85).aspx

When a 32-bit application reads from one of these folders on a 64-bit OS:

%windir%\system32\catroot
%windir%\system32\catroot2
%windir%\system32\drivers\etc
%windir%\system32\logfiles
%windir%\system32\spool 

Windows actually lists the content of:

%windir%\SysWOW64\catroot
%windir%\SysWOW64\catroot2
%windir%\SysWOW64\drivers\etc
%windir%\SysWOW64\logfiles
%windir%\SysWOW64\spool 

Thanks for your input Kris, that helped me find out what is going on.

EDIT: Thank you Ludvig too :-)

Are you sure it is looking in the same directory as the dir command? They don't seem to have any files in common.

Also, this isn't the issue, but the correct wild card for "all files" is *

*.* means "all files with at least one . in the name"

Are there any warnings when you compile?

Have you turned ALL warnings on for this particular test (since it is not working)?

Make sure first to solve the warnings.

There are no problems with the example code. I have another application that fails too, written in Delphi. I think I found the answer based on Kris' answer about redirection: http://msdn.microsoft.com/en-gb/library/aa364418(VS.85).aspx

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!