?
Solved

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

Posted on 2000-03-14
4
Medium Priority
?
559 Views
Last Modified: 2012-05-04
Hi,

I want to convert a short path name like e.g.
  "c:\progra~1\mystuff"
to
  "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.

/Brian
0
Comment
Question by:Brian_HP
  • 2
4 Comments
 
LVL 3

Accepted Solution

by:
ufolk123 earned 300 total points
ID: 2615139
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
h=FindFirstFile("c:\\progra~1",lpFindFileData)
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
0
 
LVL 31

Expert Comment

by:Zoppo
ID: 2615235
Hi Brian_HP,

At http://indigo.ie/~pjn/ in section 'Code Snippets' you can find complete code which emulates this GetLongPathName() function using FindFirstFile() API function.

hope that helps,

ZOPPO
0
 
LVL 3

Expert Comment

by:ufolk123
ID: 2615372
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++).
0
 

Author Comment

by:Brian_HP
ID: 2616198
Thanks to both of you!
/Brian
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
Suggested Courses

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question