_getcwd
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: _getcwd

  1. #1
    Join Date
    Mar 1999
    Posts
    83

    _getcwd

    I was using the _getcwd() function to get thge current working directory and I noticed that while running an app in debug, the current working directory is not the same directory as the location of the executable. I was wondering if there is a better function than _getcwd() for retreiving the working directory as I really want the directory of the executable file that is the current process.

    -T

    ====================
    Dead men don't spam.

  2. #2
    Join Date
    May 1999
    Posts
    667

    Re: _getcwd

    use
    LPCSTR getAppPath()
    { // returns path with trailing slash ex c:\temp\
    static char cPath[MAX_PATH];
    static BOOL bDone = FALSE;
    if (!bDone)
    {
    GetModuleFileName(NULL, cPath, MAX_PATH);
    char lpszDrive[_MAX_DRIVE];
    char lpszDir[_MAX_DIR];
    lpszDrive[0] = '\0';
    lpszDir[0] = '\0';
    _splitpath(cPath, lpszDrive, lpszDir, NULL, NULL);
    wsprintf(cPath, "%s%s", lpszDrive ,lpszDir);
    bDone = TRUE;
    }
    return cPath;
    }


    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
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center