Search results for 'Windows XP'. 1 post(s) found.

  1. 2008/06/16 How to search file on certain directory ?
2008/06/16 08:50

How to search file on certain directory ?


In case of finding files on certain directory, you need to use FindFirstFileEx function.

Following example shows the example,
bool KFindFile(void *findname)
{
    WIN32_FIND_DATA FindFileData;
    HANDLE hFind;

    CString strSearch = (LPCTSTR)findname;

    hFind = FindFirstFileEx( strSearch, FindExInfoStandard, &FindFileData, FindExSearchNameMatch, NULL, 0);
    if (hFind==INVALID_HANDLE_VALUE)
    {
        MessageBox( NULL, CString("Invalid Handle Value"), CString("Error"), MB_OK);

        return false;
    }
    else
    {
        MessageBox( NULL, (LPCTSTR)FindFileData.cFileName, (LPCTSTR)FindFileData.cFileName, MB_OK);

        FindClose( hFind);
        return true;
    }
}

Above source works on WIndows CE Platform as well. And you can use above function as below:
.
.
.
KFindFile( _T("\\My Documents\\My Pictures\\PIC-*.jpg"));
.
.
.


Trackback 0 Comment 0

Trackback : Cannot send a trackbact to this post.