Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to "WinExec" a search on a directory from code

Status
Not open for further replies.

Insider1984

Technical User
Feb 15, 2002
132
US
I'm familiar with WinExec but this is a new monster for me.

Basically have a directory full of dozens of images. Each image has a very specific name.

I want to be able to click a button inside my program and perform a standard windows search (with results) displayed based on a variable.

Example.

search_var= "*S02*07*F05*"
dir_var = "C:\Temp\01\"

I would then like to push a button to search "dir_var" for files that contain "search_var".

I wouldn't mind programming something but it's only to view a subset of images... not to cut copy or paste them and certain not to move them.

Thanks for the help.

=====================
Insider
4 year 'on the fly' programmer
C++ Basic Java
 
I put here a function that will returns an array of the search :
Code:
int FindFiles (CString sDirectory, CString sPattern, CStringArray& aFileNames)
{
	CFileFind finder;
	BOOL bFound = FALSE;
	aFileNames.RemoveAll();
	bFound = finder.FindFile(sDirectory+"\\"+ sPattern);
	while( bFound )
	{
		bFound= finder.FindNextFile();
		aFileNames.Add( finder.GetFileName());
	}
	return aFileNames.GetSize();

}
Example of use:
CStringArray aFiles;
CString sDir = "C:\\Inetpub\\[URL unfurl="true"]wwwroot\\images";[/URL]
CString sPattern="*r*.gif";
int nbFiles = FindFiles(sDir,sPattern,aFiles);
-obislavu-
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top