Results 1 to 8 of 8

Thread: C++ App.path

  1. #1

    Thread Starter
    Frenzied Member JasonLpz's Avatar
    Join Date
    Mar 2001
    Location
    Brooklyn, NY
    Posts
    1,335

    C++ App.path

    OK i learned how to get the app.path in vb and the the whole file path and name from c++ consol but i can i get it from Win32 c++
    - JayWare
    Live to love. Not to Hate

    Im to busy to have a site. But I got one and still working on it.

    http://dre3k.net/

  2. #2
    Hyperactive Member made_of_asp's Avatar
    Join Date
    Jul 2001
    Location
    123 Fake Street
    Posts
    394
    GetCurrentDirectory() should take care of it.

    Then you can manage the directory with PathCombine().
    VS.NET 2003

    Need to email me?

  3. #3
    Frenzied Member Zaei's Avatar
    Join Date
    Jul 2002
    Location
    My own little world...
    Posts
    1,710
    Originally posted by made_of_asp
    GetCurrentDirectory() should take care of it.

    Then you can manage the directory with PathCombine().
    You cant guarentee that the current directory is the same as the application path. I believe that MSVC will change the current directory to the one the executable resides in when in Debug/Run mode, however, in the real world, dont bet on it.

    Use GetModuleFilename(), and trim it backwards until you hit a '\\' character.

    Z.

  4. #4

    Thread Starter
    Frenzied Member JasonLpz's Avatar
    Join Date
    Mar 2001
    Location
    Brooklyn, NY
    Posts
    1,335
    thanks alot . i would have thought it would have been complicate dbut you made it simple lol thanks again
    - JayWare
    Live to love. Not to Hate

    Im to busy to have a site. But I got one and still working on it.

    http://dre3k.net/

  5. #5
    Hyperactive Member made_of_asp's Avatar
    Join Date
    Jul 2001
    Location
    123 Fake Street
    Posts
    394
    TRUE. Current Directory can change, but I always use it anyway. You would have to modify your shortucts ""Working Directory" function.

    Code:
    #include <shlwapi.h>
    
    void Mod()
    {
    	CHAR szModule[2048];
    
    	GetModuleFileName(GetModuleHandle(NULL), szModule, 2048);
    ::PathRemoveFileSpec(szModule);
    	MessageBox(NULL, szModule, "AAA", MB_OK);
    }
    Last edited by made_of_asp; Jan 28th, 2003 at 10:37 PM.
    VS.NET 2003

    Need to email me?

  6. #6
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    MSVC++ sets the working directory in debug runs to the project main directory, which is not where the exe resides in.

    Unlike VC# btw...
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  7. #7
    Frenzied Member Zaei's Avatar
    Join Date
    Jul 2002
    Location
    My own little world...
    Posts
    1,710
    Originally posted by CornedBee
    MSVC++ sets the working directory in debug runs to the project main directory, which is not where the exe resides in.

    Unlike VC# btw...
    It is in my projects

    Z.

  8. #8
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    Well...
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

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