Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

C++: GetTempPath() without tilde (~)

I need to get temp path. So I tried GetTempPath() and std::getenv("TEMP"). The problem is that the result contains ~ symbol, for example C:\Users\OLEKSI~1.ALE\AppData\Local\Temp.
Is it possible to get full temp path like C:\Users\Oleksii\AppData\Local\Temp?

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

GetLongPathName function:

Converts the specified path to its long form.

DWORD GetLongPathNameW(
  [in]  LPCWSTR lpszShortPath,
  [out] LPWSTR  lpszLongPath,
  [in]  DWORD   cchBuffer
);

DWORD GetLongPathNameA(
  [in]  LPCSTR lpszShortPath,
  [out] LPSTR  lpszLongPath,
  [in]  DWORD  cchBuffer
);

Set lpszShortPath = short path with ~ symbols. Read result from lpszLongPath.

GetLongPathName

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading