[Interest] using windows FindFirstFile

Graham Labdon Graham.Labdon at avalonsciences.com
Wed Feb 15 12:58:32 CET 2012


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<http://www.avalonsciences.com>
Company no. 2147892
Registered in England & Wales
Registered office: Avalon House Somerton TA11 6SB

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20120215/19601a39/attachment.html>


More information about the Interest mailing list