How to search file on certain directory ?

CK1820 
Created at Jun 15, 2008 23:50:59 
56   0   0   0  
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"));
.
.
.




Tags: C++ Event Call MFC Search File WIN32 API WIndows CE WinCE Windows XP Share on Facebook Share on X

◀ PREVIOUS
SQL to Select a random row from a database table
▶ NEXT
FNC(Photo/Video File Name Changer) v1.0 release
  Comments 0
Login for comment
SIMILAR POSTS

How to call SetTimer function on MFC CDialog class ? (created at Jul 30, 2008)

How to load HTML resource on MFC ? (updated at Dec 17, 2023)

How to run shell command by MFC ? (created at Sep 09, 2007)

URL Encode, Decode function for MFC (updated at Dec 20, 2023)

Binary Search Sample Code (created at Sep 08, 2007)

Double Linked List based in C++ (created at Sep 08, 2007)

MFC based World Wide Web HTTP Server Source Code (created at Aug 28, 2007)

Creating and Using a CAsyncSocket Object to use CAsyncSocket (created at Aug 28, 2007)

UDP Send and Receive Using CAsyncSocket (created at Aug 28, 2007)

Using the shell to receive notification of removable media being inserted or removed (created at Aug 28, 2007)

Fast and Good Keyboard/Mouse Test without the message handler (created at Aug 27, 2007)

Simple CGI Programming in C (created at Aug 27, 2007)

C++ CGI Example working on Apache (created at Aug 27, 2007)

KMP String Matching Algorithm (created at Jul 21, 2010)

OTHER POSTS IN THE SAME CATEGORY

FNC(Photo/Video File Name Changer) v1.1 Release - Date Time Bug Fix & Retry Function Added (created at Jun 11, 2013)

Smart TV Cycling Apps – TV for Fitness (created at Apr 24, 2013)

The public could reduce server cost, and enhance performance for global service distribution (created at Jun 17, 2012)

Cloud gaming coming to Samsung Smart TVs (created at Jun 05, 2012)

Kids App – Kids Learn While Parents Control on Samsung Smart TV (created at May 13, 2012)

Fitness Hub presents your personal trainer, Fitness VOD on Samsung Smart TV (created at Apr 10, 2012)

Word counting source program based on MapReduce framework (updated at Dec 17, 2023)

The leaders who created Smart TV (created at Nov 01, 2011)

FNC(Photo/Video File Name Changer) v1.02 release - The file created date time information is available for those cameras providing incorrect EXIF data (updated at Dec 20, 2023)

Samsung Apps hits 5 million Smart TV app downloads (created at May 23, 2011)

Your Video – VoD content recommendation service on Samsung Smart TV (created at Mar 15, 2011)

Amazon S3 File Explorer : You can use S3 like Windows File Explorer (created at Oct 02, 2010)

Where to get AWS Access Key ? (updated at Dec 21, 2023)

FNC(Photo/Video File Name Changer) v1.01 release (updated at Dec 20, 2023)

FNC(Photo/Video File Name Changer) v1.0 release (updated at Dec 20, 2023)

SQL to Select a random row from a database table (created at Jan 07, 2008)

DataPlay – Change the world with brand new media (created at Oct 16, 2001)

Content Manager for The world’s first MP3 Phone (created at Jul 31, 2000)

yepp Explorer – File Management Application for MP3 Device (created at Feb 21, 2000)

MusicDrive – DRM enabled Secure Music Player on Microsoft Windows (created at Feb 16, 2000)

UPDATES

Creating a Pinterest-Style Card Layout with Bootstrap and Masonry (created at Apr 24, 2024)

Mastering Excel Data Importation in PHP (updated at Apr 24, 2024)

JSON format control in PHP (updated at Apr 24, 2024)

Equal Height Blocks in Bootstrap with JavaScript (created at Apr 22, 2024)

How to convert integer to text string ? (updated at Apr 22, 2024)

Checking similarity between two strings in PHP (updated at Apr 21, 2024)

Create Blob Image in HTML based on the given Text, Width and Height in the Center of the Image without saving file (updated at Apr 21, 2024)

How do I determine the client IP type (IPv4/IPv6) in PHP (updated at Apr 16, 2024)

How do I determine the client IP type in Python - IPv4 or IPv6 (updated at Apr 13, 2024)

Getting Started with PyTorch: A Beginner's Guide to Building Your First Neural Network (updated at Apr 09, 2024)

Predicting Buyer Preferences with PyTorch: A Deep Learning Approach (updated at Apr 09, 2024)

Forecasting the Weather with PyTorch: A Beginner's Guide to Temperature Prediction (created at Apr 09, 2024)

PyTorch example to Forcast Stock Price based on 10 days Dataset (created at Apr 09, 2024)

Mastering Model Persistence: Saving and Loading Trained Machine Learning Models in Python (created at Apr 08, 2024)

Harnessing the Power of Random Forest Algorithm in Python (created at Apr 08, 2024)

Understanding and Implementing K-Nearest Neighbors (KNN) Algorithm in Python (created at Apr 08, 2024)

Forecasting with Linear Regression and KNN Regression in Python (updated at Apr 07, 2024)

What is 302 Found Redirection in HTTP 1.1? (created at Apr 04, 2024)

Mastering Random Forest Regression: A Comprehensive Guide with Python Examples (updated at Apr 01, 2024)

Python Implementation of Linear Regression (updated at Apr 01, 2024)

Mastering Supervised Machine Learning with Python: A Comprehensive Guide (created at Apr 01, 2024)

Mastering AI: A Beginner's Guide to Python Programming and Beyond (created at Apr 01, 2024)

How do I create animated background for Google Meet? (updated at Mar 28, 2024)

Building a Simple DNS Server in Delphi with TTL Support (created at Mar 16, 2024)

How to force cookies, disable php sessid in URL ? (updated at Mar 16, 2024)

Implementing a Versatile DNS Server in PHP: Handling A, AAAA, CNAME, and TXT Records (updated at Mar 16, 2024)

Implementing a Versatile DNS Server in Python: Handling A, AAAA, CNAME, and TXT Records (created at Mar 16, 2024)

Building a Basic DNS Server in PHP/Python: A Beginner's Guide (updated at Mar 15, 2024)

Dynamic DNS Made Easy: Building a Python-Based Solution (created at Mar 15, 2024)

Exploring the Depths of Data Transfer: sendfile vs. kTLS (created at Mar 15, 2024)