How do I convert a short path name to a long path name


I want to convert a short path name like e.g.
  "c:\program files\mystuff"

I found the function GetLongPathName, but this only works for WinNT 5.0 and Win98 and later versions. The function GetFullPathName doesn't help me either.

Who is Participating?
ufolk123Connect With a Mentor Commented:
Hi Brian HP.

There is ont technique you can use:

FindFirstFile() give you the long path name of a file given the short path name (8.3 style) path name.

For example
will return you program files in lpFindFileData cFileName field.
May be you can invoke this funciton for each path component and strcat them to get the Windows style full path name.

Hope this helps
Hi Brian_HP,

At in section 'Code Snippets' you can find complete code which emulates this GetLongPathName() function using FindFirstFile() API function.

hope that helps,

Yes code snippen by ZOPPO looks ok and on the same lines as i suggested but it uses CString .You may have to modify the code a little if yours is pure C Win32 APP as CString is not portable (Only in VC++).
Brian_HPAuthor Commented:
Thanks to both of you!
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.