GetTempPathA how would I know size in advance?

  ansi, c++, unicode, winapi, windows

I am coding in C, using the Windows API.

I was looking at the GetTempPathA() function here, and have included the function’s syntax below.

DWORD GetTempPathA(
  DWORD nBufferLength,
  LPSTR lpBuffer

I can see the path will be stored in lpBuffer, but I could not understand how I am expected to know what size to set the DWORD nBufferLength to – I expect people with more Windows development experience will tell me it is one value for ANSI language systems and another for Unicode, but I would rather ask the professionals here on Stackoverflow for guidance?

I would assume it needs to be set to the longest value possible for a file path, as perhaps the user somehow changed the default location to a longer path elsewhere on the system, but I am only guessing.

This appears to be just an ANSI function, however during my time looking over the documentation on MSDN I often find functions which have an ANSI and Unicode function (which end in A and W respectively). I do understand the difference between them, but if I had to create a buffer what would the maximum input size be?

Lastly, when answering please keep in mind that I do enjoy writing backwards compatible applications, as many of my friends live in third world countries without access to the latest Windows operating systems.

Source: Windows Questions