[Interest] using windows FindFirstFile

norulez at me.com norulez at me.com
Wed Feb 15 13:29:57 CET 2012


Use QDir::toNativeSeparators() which replace slashes with backslashes

Best Regards

Am 15.02.2012 um 12:58 schrieb Graham Labdon <Graham.Labdon at avalonsciences.com>:

> Hi
> I am trying to use the windows FindFirstFile function.
> 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?
>  
> Thanks
>  
> #ifdef Q_OS_WIN
>   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);
>   if (hFind == INVALID_HANDLE_VALUE)
>   {
>         int error;
>         error = GetLastError();
>   }
>   else
>   {
> #ifdef UNICODE
>       qDebug() << QString::fromUtf16((ushort*)FindFileData.cFileName);
> #else
>   qDebug() << QString::fromLocal8Bit(FindFileData.cFileName);
> #endif
>   }
> #endif
>  
>  
>  
> Graham Labdon
>  
> Senior Software Engineer
> Avalon Sciences Limited
> Tel:     +44 (0) 1458 271035
> www.avalonsciences.com
> Company no. 2147892
> Registered in England & Wales
> Registered office: Avalon House Somerton TA11 6SB
>  
> _______________________________________________
> Interest mailing list
> Interest at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/interest
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20120215/5fd0bfa5/attachment.html>


More information about the Interest mailing list