I want to implement according to the following specification:

FindFirst

Search a directory for a file or subdirectory whose name matches the specified parameter.

long FindFirst(LPCTSTR ItemName)

Parameters
ItemName
[in] string that specifies a valid directory or path and file name, which can contain wildcard characters, such as * and ?.

Return Value
A nonzero search handle (FindID) that can be used in a subsequent call to FindNext, FindClose, FindProp, indicates success. Zero indicates failure.

Remarks
FindFirst opens a search handle (FindID) and stores information about the first item whose name matches the specified pattern. Once the search handle is established, you can use FindNext to search for other items that match the same pattern. Use FindProp to access item properties. When the search handle is no longer needed, close it using FindClose function. See Win32 FindFirstFile function

FindNext

Continue a search from a previous call to FindFirst

long FindNext(long FindID);

Parameters
FindID
[in] search handle returned by a previous call to FindFirst.

Return Value
Zero indicates success. Nonzero indicates a Win32 system error code related to the failure. ERROR_NO_MORE_FILES means no other matching items can be found.

Remarks
When the search ends, close search handle using FindClose. See Win32 FindNextFile function.


FindClose

Close a search from a previous call to FindFirst

long FindClose(long FindID);

Parameters
FindID
[in] search handle returned by a previous call to FindFirst.

Return Value
Zero indicates success. Nonzero indicates a Win32 system error code related to the failure.

Remarks
After FindClose the search handle is no longer valid and cannot be used in subsequent calls to FindNext, FindClose, FindProp. See Win32 FindClose function.


FindProp

Get a property of the item (directory / file) found with previous call to FindFirst or FindNext

VARIANT FindProp(long FindID, long PropID);

Parameters
FindID
[in] search handle returned by a previous call to FindFirst, FindNext.

PropID
[in] identifier of desired item property. It can be one of:
1 (Type)
2 (CreationTime)
3 (LastAccessTime)
4 (LastWriteTime)
5 (Size)
6 (Name)

Return Value
The type and content of the Variant depends on PropID. The returned value contains 0 or an empty string if previous FindFirst, FindNext could not find any item (completed with ERROR_NO_MORE_FILES / null search handle).

PropID=Type:
VT_I4 with same values as Win32 WIN32_FIND_DATA.dwFileAttributes

PropID=CreationTime:
VT_DATE with SYSTEMTIME elements
Empty VT_BSTR if the system does not keep track of this information for the item found

PropID=LastAccessTime:
VT_DATE with SYSTEMTIME elements
Empty VT_BSTR if the system does not keep track of this information for the item found


PropID=LastWriteTime:
VT_DATE with SYSTEMTIME elements
Empty VT_BSTR if the system does not keep track of this information for the item found

PropID=Size:
VT_CY with the item size in bytes

PropID=Name:
VT_BSTR with the item name (not the whole path, the simple name only)


Please help me finding the solution...........

may be u can try this

char cmd[200];
strcpy(cmd, "ls ");
strcat(cmd, pattern);
strcat(cmd, " ");
strcat(cmd, "> itemlist.tmp");
system(cmd);

/*parse the file 'itemlist.tmp' to get all the matching items*/
/*u can use the 'file' command to get info about the item*/
/*or instead of ls u can use 'ls -ltr' which will give all the info. U just need to parse the output properly*/
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.