Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 264
  • Last Modified:

Need to learn how to search using visual c++ 6

Background..

I am a very new programmer i have made a few very small programs for friends.. but i am currently trying to advance my skills and test myself as well as helping friends by making a program that goes through their computers and looks for files.. (eg. norton, internet security, firewalls, codecs, temp files, cookies, reg files, amd then suggest where to get updates and certain codecs and weather they should get antiviruses so on so forth)

Question...

Can someone supply me with the filesearching code (i have no idea so please document) including all headers needed etc etc..and if u want the code to search through reg files.. or if ur feeling lazy even reccomend a site with a link.. all i want to do is learn and test my skills.. any help appreciated

i have given top points ranking for this
any probs u can email me @        wazzup_scott01@hotmail.com
0
Scott Thomson
Asked:
Scott Thomson
  • 2
  • 2
1 Solution
 
nonubikCommented:
Here's a function that search through a given folder name (and its subfolders) the reg files:

void DoIt(LPCTSTR szDir)
{
  CFileFind   Finder;
  CString     strPath(szDir);
  strPath += "\\*.reg";
  BOOL bFind = Finder.FindFile(strPath);
  while(bFind)
  {
    bFind = Finder.FindNextFile();
   
    // skip . and .. files; otherwise, we'd
    // recur infinitely!
    if(Finder.IsDots())
         continue;

    // if it's a directory, recursively search it
    if (Finder.IsDirectory())
      DoIt(Finder.GetFilePath());
    else
      //Use Finder.GetFilePath() to get the path. Copy file after extension check here.
  }
}

This code uses MFC, so no other additional includes are necessary.
0
 
Scott ThomsonAuthor Commented:
the code works (compiles with no errors..

and i will award u points but also can u perhaps explain a little... simpler (im an idiot)

perhaps where to put the directory or weather this is user input generated.. and does it search registry.. prolly not..

once again thanks and any help appreciated
0
 
nonubikCommented:
The above function takes as inpunt a folder name. You can use it like:

DoIt("c:\\");

and it will search all .reg files on C:\. But of course this can take quite a long time.
I'm not sure if you want to search for the .reg files or to search through the registry.
To search through the registry you'll need to use Registri functions: RegCreateKeyEx, RegQueryValueEx, RegCloseKey, etc. (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/sysinfo/base/registry_functions.asp)
0
 
Scott ThomsonAuthor Commented:
awesome man.. purely awesome

id love to be as good as you..
u must have a kick ass programming job or something

thanks it works awesomely
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now