Note that there are some explanatory texts on larger screens.

plurals
  1. POFindNextFile fails on 64-bit Windows?
    text
    copied!<p>using C++Builder 2007, the FindFirstFile and FindNextFile functions doesn't seem to be able to find some files on 64-bit versions of Vista and XP. My test application is 32-bit.</p> <p>If I use them to iterate through the folder C:\Windows\System32\Drivers they only find a handful of files although there are 185 when I issue a dir command in a command prompt. Using the same example code lists all files fine on a 32-bit version of XP.</p> <p>Here is a small example program:</p> <pre><code>int main(int argc, char* argv[]) { HANDLE hFind; WIN32_FIND_DATA FindData; int ErrorCode; bool cont = true; cout &lt;&lt; "FindFirst/Next demo." &lt;&lt; endl &lt;&lt; endl; hFind = FindFirstFile("*.*", &amp;FindData); if(hFind == INVALID_HANDLE_VALUE) { ErrorCode = GetLastError(); if (ErrorCode == ERROR_FILE_NOT_FOUND) { cout &lt;&lt; "There are no files matching that path/mask\n" &lt;&lt; endl; } else { cout &lt;&lt; "FindFirstFile() returned error code " &lt;&lt; ErrorCode &lt;&lt; endl; } cont = false; } else { cout &lt;&lt; FindData.cFileName &lt;&lt; endl; } if (cont) { while (FindNextFile(hFind, &amp;FindData)) { cout &lt;&lt; FindData.cFileName &lt;&lt; endl; } ErrorCode = GetLastError(); if (ErrorCode == ERROR_NO_MORE_FILES) { cout &lt;&lt; endl &lt;&lt; "All files logged." &lt;&lt; endl; } else { cout &lt;&lt; "FindNextFile() returned error code " &lt;&lt; ErrorCode &lt;&lt; endl; } if (!FindClose(hFind)) { ErrorCode = GetLastError(); cout &lt;&lt; "FindClose() returned error code " &lt;&lt; ErrorCode &lt;&lt; endl; } } return 0; } </code></pre> <p>Running it in the C:\Windows\System32\Drivers folder on 64-bit XP returns this:</p> <pre><code>C:\WINDOWS\system32\drivers&gt;t:\Project1.exe FindFirst/Next demo. . .. AsIO.sys ASUSHWIO.SYS hfile.txt raspti.zip stcp2v30.sys truecrypt.sys All files logged. </code></pre> <p>A dir command on the same system returns this:</p> <pre><code>C:\WINDOWS\system32\drivers&gt;dir/p Volume in drive C has no label. Volume Serial Number is E8E1-0F1E Directory of C:\WINDOWS\system32\drivers 16-09-2008 23:12 &lt;DIR&gt; . 16-09-2008 23:12 &lt;DIR&gt; .. 17-02-2007 00:02 80.384 1394bus.sys 16-09-2008 23:12 9.453 a.txt 17-02-2007 00:02 322.560 acpi.sys 29-03-2006 14:00 18.432 acpiec.sys 24-03-2005 17:11 188.928 aec.sys 21-06-2008 15:07 291.840 afd.sys 29-03-2006 14:00 51.712 amdk8.sys 17-02-2007 00:03 111.104 arp1394.sys 08-05-2006 20:19 8.192 ASACPI.sys 29-03-2006 14:00 25.088 asyncmac.sys 17-02-2007 00:03 150.016 atapi.sys 17-02-2007 00:03 106.496 atmarpc.sys 29-03-2006 14:00 57.344 atmepvc.sys 17-02-2007 00:03 91.648 atmlane.sys 17-02-2007 00:03 569.856 atmuni.sys 24-03-2005 19:12 5.632 audstub.sys 29-03-2006 14:00 6.144 beep.sys Press any key to continue . . . etc. </code></pre> <p>I'm puzzled. What is the reason for this?</p> <p>Brian</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload