Solved

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

Posted on 2000-03-14
4
542 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 3

Accepted Solution

by:
ufolk123 earned 100 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…

737 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