-1

I am programming a basic win shell in c++ and one of the request is to support the function that prints the current ("chosen") path(basically does what "echo %cd%" does)... can some one please post the command name and/or usage. I have been searching google for about a hour

  • 1
    [`GetCurrentDirectory()`](https://msdn.microsoft.com/en-gb/library/windows/desktop/aa364934(v=vs.85).aspx)? – Alex K. Apr 02 '16 at 16:43
  • 3
    -1: An hour isn't a very long time. You're expected to get used to performing your own research. If that means you have to read through the WinAPI docs for a day or two, then so be it ... and you'll be better off for it because afterwards you'll know where to look for things in future. Spoon-feeding you function names doesn't teach you anything at all. Also, you may wish to work on improving your searching skills, because the answer is literally the first result for `windows api current directory` on Google. – Lightness Races in Orbit Apr 02 '16 at 16:50
  • Maybe your user referred to `PATH`, which has nothing to do with current directory? – Cheers and hth. - Alf Apr 02 '16 at 16:50

2 Answers2

2

The function you're looking for is GetCurrentDirectory.

You were probably having difficulty finding it because you didn't know what words to search for. I found it by searching for "windows api get working directory."

IanPudney
  • 5,941
  • 1
  • 24
  • 39
2

The WinAPI function is:
GetCurrentDirectory
The link shows C++ usage of that WinAPI function.

Here is an example that uses the function in a full console program:
Changing The Current Directory

This function is platform specific:
windows.h > winbase.h > kernel32.dll

Baronz
  • 667
  • 5
  • 16