DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 4 of 4

Thread: C++ file searching and executeable launching on Windows

  1. #1
    ADB Guest

    C++ file searching and executeable launching on Windows


    Hello,

    Can anyone give me some ideas on how to search for a file (assuming I know

    the directory to search in) for a particular file?

    Also, how can I launch another executeable from a C++ program?

    Thanks.

    Aaron


  2. #2
    steve Guest

    Re: C++ file searching and executeable launching on Windows


    HI.

    To search for a file use something like.

    The 'default' is to use the current directory - seed the findfile with a
    path to search elsewhere...
    CFileFind FF;
    BOOL bFound = FindFile(_T("C:\\*.*"));

    Don't forget to check for IsDots() and IsDirectory().



    2) to load an exe from within your program use:

    ShellExecute(0, _T("open"), "path to exe here", 0, 0, SW_SHOWNORMAL);

    not sure of its exact use but the shellexecute command does this stuff.

    Hope this helps.

    STEVE

  3. #3
    Aaron Guest

    Re: C++ file searching and executeable launching on Windows


    "steve" <sautrn2856@aol.com> wrote:
    >
    >HI.
    >
    >To search for a file use something like.
    >
    >The 'default' is to use the current directory - seed the findfile with a
    >path to search elsewhere...
    > CFileFind FF;
    > BOOL bFound = FindFile(_T("C:\\*.*"));
    >
    >Don't forget to check for IsDots() and IsDirectory().
    >
    >
    >
    >2) to load an exe from within your program use:
    >
    >ShellExecute(0, _T("open"), "path to exe here", 0, 0, SW_SHOWNORMAL);
    >
    >not sure of its exact use but the shellexecute command does this stuff.
    >
    >Hope this helps.
    >
    >STEVE


    Hey Steve,

    I've been doing some reading on the FileFind() function on the msdn website

    and it lists this function as part of the CFileFind class, which is defined
    in the "afx.h" library. A sample of my test code is as follows:

    #include <afx.h>

    void main()
    {
    CFileFind finder;

    BOOL bWorking = finder.FindFile("c:\\TestFile.txt");

    if(bWorking)
    cout << "File: " << (finder.GetFileName() << " Found!" << endl;
    else
    cout << "File NOT Found!!" << endl;
    }

    However, I get the following errors:
    nafxcwd.lib(thrdcore.obj) : error LNK2001: unresolved external symbol __endthreadex
    nafxcwd.lib(thrdcore.obj) : error LNK2001: unresolved external symbol __beginthreadex
    Debug/AnalyzerSetup.exe : fatal error LNK1120: 2 unresolved externals

    Am I right in including the afx library?

    Thanks


  4. #4
    ralph Guest

    Re: C++ file searching and executeable launching on Windows


    "Aaron" <adbriscoe@yahoo.com> wrote:
    >
    >"steve" <sautrn2856@aol.com> wrote:
    >>
    >>HI.
    >>
    >>To search for a file use something like.
    >>
    >>The 'default' is to use the current directory - seed the findfile with

    a
    >>path to search elsewhere...
    >> CFileFind FF;
    >> BOOL bFound = FindFile(_T("C:\\*.*"));
    >>
    >>Don't forget to check for IsDots() and IsDirectory().
    >>
    >>
    >>
    >>2) to load an exe from within your program use:
    >>
    >>ShellExecute(0, _T("open"), "path to exe here", 0, 0, SW_SHOWNORMAL);
    >>
    >>not sure of its exact use but the shellexecute command does this stuff.
    >>
    >>Hope this helps.
    >>
    >>STEVE

    >
    >Hey Steve,
    >
    >I've been doing some reading on the FileFind() function on the msdn website
    >
    >and it lists this function as part of the CFileFind class, which is defined
    >in the "afx.h" library. A sample of my test code is as follows:
    >
    >#include <afx.h>
    >
    >void main()
    >{
    > CFileFind finder;
    >
    > BOOL bWorking = finder.FindFile("c:\\TestFile.txt");
    >
    > if(bWorking)
    > cout << "File: " << (finder.GetFileName() << " Found!" << endl;
    > else
    > cout << "File NOT Found!!" << endl;
    >}
    >
    >However, I get the following errors:
    >nafxcwd.lib(thrdcore.obj) : error LNK2001: unresolved external symbol __endthreadex
    >nafxcwd.lib(thrdcore.obj) : error LNK2001: unresolved external symbol __beginthreadex
    >Debug/AnalyzerSetup.exe : fatal error LNK1120: 2 unresolved externals
    >
    >Am I right in including the afx library?
    >
    >Thanks
    >


    You have mixed "thread" options in your compiler options and/or have mixed
    CLib/MFCLib libraries and subsequent startup code.
    Make sure you are using multi-thread libraries through out.



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center