I have a Windows API task: "Define and output the current directory for the process and for each disk."

Did I understand correctly and complete the task? What does it mean for each disc?

void get_current_dir(TCHAR dirname[]) { TCHAR *fileExt = NULL; TCHAR szDir[MAX_PATH]; GetFullPathName(dirname, MAX_PATH, szDir, &fileExt); _tprintf(_T("Full path: %s \nFilename: %s\n"), szDir, fileExt); } int main () { TCHAR dirname[] = TEXT("C:"); get_current_dir(dirname); } 

UPD:

It seems to figure out how to get the current directory of the current disk.

 void get_current_process_dir() { char* buffer = new char[MAX_PATH]; GetCurrentDirectoryA(MAX_PATH, buffer); CharToOemA(buffer, buffer); cout << buffer << endl; } 
  • @khusaenov, If you are given an exhaustive answer, mark it as correct (click on the check mark next to the selected answer). - Nicolas Chabanovsky

1 answer 1

No, the current process directory is the one in which the file is saved, if you save it with the name without a disk and path. The current directory of the disk is the one in which the file is saved, if you save it with an indication of the disk and name, but without the path.

  • @maxleo: And how does this contradict the code in question? - VladD
  • @VladD, he found the second (but only for one disk), considering that the first one was found. - maxleo
  • @maxleo: Ah, in that sense, yes. - VladD
  • @maxleo @VladD I didn’t really understand, could you help me figure it out, give more detailed information, with an example of what the current disk directory and current process directory are. - user16639