CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Apr 2005
    Location
    Eden Prairie, MN
    Posts
    18

    Searching for file on hard drives

    I need to launch another guy's executable from my app's menu item.
    The problem is that the user can install that executable anywhere on the system, either before or after they install my app. The other guy is not writing any info about his app's location to registry.

    I've started by looping through the system drives and doing FindNextFile(), checking to see if it's a directory and if so, checking all the files inside, etc. (See below.) But I'm thinking there has to be a better way. If anyone has some suggestions or sample code to share, I'd sure appreciate it.
    Code:
    WIN32_FIND_DATA &findData;
    HANDLE hFind;
    while ( FindNextFile( hFind, &findData ) )
    {
         if ( findData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY )
         {
              // search for files in this directory
         }
         else if ( findData.cFileName == otherGuysExecutableName )
         {
              // return absolute path to executable
         }
    }

  2. #2
    Join Date
    Jun 2005
    Location
    Chennai , India
    Posts
    1,375

    Thumbs up Re: Searching for file on hard drives

    It takes seconds for rating…that actually compensates the minutes taken for giving answers
    The biggest guru-mantra is: Never share your secrets with anybody. It will destroy you.
    Regards, Be generous->Rate people
    Jayender!!

  3. #3
    Join Date
    May 2005
    Posts
    4,954

    Re: Searching for file on hard drives

    If a post helped you dont forget to "Rate This Post"

    My Article: Capturing Windows Regardless of Their Z-Order

    Cheers

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured