Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Getting the working directory.

Status
Not open for further replies.

zikar

Programmer
Oct 10, 2000
31
JP
Hi,

I have a little application running on a Pocket PC.
How do I know the working directory from inside the application ?
I need to know that to be able to save data at the same place where the application resides and not at the root.

Michel
 
I assume you do not want to know the working directory, but the directory where the .exe file is located.
The GetModuleFileName() Win32 API function tells you that:
Code:
  TCHAR appPath[MAX_PATH+1];
  if( GetModuleFileName(NULL, appPath, MAX_PATH) == 0 )
  {
    //failure
  }
  else
  {
    CString tmpStr(appPath);
    int pos = tmpStr.ReverseFind((TCHAR)'\\');
    if( pos == -1 )
    {
       // your EXE is in the root directory
    }
    else
    {
      appPath[pos] = (TCHAR)'\0';  // that's it!
    }
  }
 
Thanks a lot. It works.

I know I am late to answer.

But anyway thanks. I was busy and didn't have time to read this before ...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top