[Interest] using windows FindFirstFile
David Ching
dc at dcsoft.com
Wed Feb 15 19:01:08 CET 2012
> Date: Wed, 15 Feb 2012 11:58:32 +0000
> From: Graham Labdon <Graham.Labdon at avalonsciences.com>
> Subject: [Interest] using windows FindFirstFile
>
> In the code below the call to FindFirstFile always fails with the error
'ERROR_INVALID_NAME'
> The file that I set in searchPath does exist.
> Does anyone know the correct way to do this?
> ...
> WIN32_FIND_DATA FindFileData;
> HANDLE hFind;
> QString searchPath = "C:/jobs/daryll/Rcd/f_000001.rcd";
> WCHAR p[100];
> int x = searchPath.toWCharArray(p);
> hFind = FindFirstFile(p, &FindFileData);
First, you should declare
WCHAR p[MAX_PATH]; // MAX_PATH is max length of a Windows path gotten
from <drive>:<path> syntax
The real problem is searchPath should be e.g.
QString searchPath = "C:/jobs/daryll/Rcd/*"; // include wildcard '*'
-- David
More information about the Interest
mailing list