CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Join Date
    Aug 1999
    Posts
    33

    Getting full path to my application - How?

    I want to put version information in my About box and an audit table in my db. To do this, I call GetFileVersionInfoSize(), which requires a full path to my exe. Surely there is a MFC or WinAPI call that will get me that info. Can someone point me to the call?

    thanx

  2. #2
    Join Date
    Dec 2001
    Location
    Ontario, Canada
    Posts
    2,236
    Its always argv[0].

  3. #3
    Join Date
    Nov 2001
    Posts
    401

    Here is the code u can use

    char szAppPath[MAX_PATH] = "";
    CString strAppDirectory;

    ::GetModuleFileName(0, szAppPath, sizeof(szAppPath) - 1);

    // Extract directory
    // Note, that the extra spaces around \\ are only for display //reasons here...
    strAppDirectory = szAppPath;//AfxMessageBox(strAppDirectory );
    strAppDirectory = strAppDirectory.Left(strAppDirectory.ReverseFind('\\'));

  4. #4
    Join Date
    Aug 1999
    Posts
    33

    Thanx!

    That was exactly what I needed!

  5. #5
    Join Date
    Feb 2001
    Location
    AZ
    Posts
    201
    MSDN says this about GetFileVersionInfoSize:


    lptstrFilename [in] Pointer to a null-terminated string that specifies the name of the file of interest. The function uses the search sequence specified by the LoadLibrary function.

    So you shouldn't need to specify the full path.

    Regards,
    Hal

  6. #6
    Join Date
    May 2000
    Location
    KY, USA
    Posts
    18,652
    A simple search through the FAQs would have been revealed this one...

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