DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 3 of 3

Thread: Find application path

  1. #1
    Adam Dawes Guest

    Find application path

    I have an application that I've written in MFC, but I've run into a problem
    that I don't know how to solve.

    I need to be able to find the path in which my application's executable is
    located (the equivalent of VB's App.Path property). I've tried using the
    _getcwd function from <direct.h> and that works fine when the program is
    launched by double-clicking its icon, but when a shortcut is used to start
    it, the cwd is pointing to the shortcut location instead of the exe
    location.

    Can anyone suggest a way that I can find the path I'm looking for under all
    conditions?

    My thanks in advance,

    --

    Adam.
    www.adamdawes.com




  2. #2
    Christof Helm Guest

    Re: Find application path

    GetModuleFilename( NULL, sFilename, dwMaxLen ) is your friend.

    hth,
    Chris

    Adam Dawes wrote:

    > I have an application that I've written in MFC, but I've run into a problem
    > that I don't know how to solve.
    >
    > I need to be able to find the path in which my application's executable is
    > located (the equivalent of VB's App.Path property). I've tried using the
    > _getcwd function from <direct.h> and that works fine when the program is
    > launched by double-clicking its icon, but when a shortcut is used to start
    > it, the cwd is pointing to the shortcut location instead of the exe
    > location.
    >
    > Can anyone suggest a way that I can find the path I'm looking for under all
    > conditions?
    >
    > My thanks in advance,
    >
    > --
    >
    > Adam.
    > www.adamdawes.com



  3. #3
    Adam Dawes Guest

    Re: Find application path

    Brilliant -- thank you!

    --

    Adam.
    www.adamdawes.com


    "Christof Helm" <c.helm@freenet.de> wrote in message
    news:3A06857C.D4210E60@freenet.de...
    > GetModuleFilename( NULL, sFilename, dwMaxLen ) is your friend.
    >
    > hth,
    > Chris





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