Solved

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

Posted on 2000-03-14
4
534 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 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

919 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now