Solved

Long name from DOS short name

Posted on 2002-05-16
6
222 Views
Last Modified: 2013-11-20
Hi - Say that I have a CString that contains a valid file name, but it uses the short name like "C:\progra~1\my~1.txt"

How can I get a CString that looks like:
1 - "C:\Program Files\My File.txt"

and (not required, but would be nice)

2 - "\\mymachine\c\Program Files\My File.txt"

My main target is NT4.0.

Any help would be great.
0
Comment
Question by:marcus78
[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
  • 3
  • 2
6 Comments
 
LVL 86

Accepted Solution

by:
jkr earned 75 total points
ID: 7014290
Use 'GetShortPathName()':

GetShortPathName
The GetShortPathName function obtains the short path form of a specified input path.

DWORD GetShortPathName(
  LPCTSTR lpszLongPath,  // pointer to a null-terminated path string
  LPTSTR lpszShortPath,  // pointer to a buffer to receive the
                         // null-terminated short form of the path
  DWORD cchBuffer        // specifies the size of the buffer pointed
                         // to by lpszShortPath
);
 
Parameters
lpszLongPath
Pointer to a null-terminated path string. The function obtains the short form of this path.
lpszShortPath
Pointer to a buffer to receive the null-terminated short form of the path specified by lpszLongPath.
cchBuffer
Specifies the size, in characters, of the buffer pointed to by lpszShortPath.
0
 
LVL 86

Expert Comment

by:jkr
ID: 7014297
0
 
LVL 3

Expert Comment

by:Crius
ID: 7014399
I think you have it backwards jkr. :) I believe marcus78 wants GetLongPathName() instead...
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 86

Expert Comment

by:jkr
ID: 7014419
You are right :o)
0
 

Author Comment

by:marcus78
ID: 7014421
Crius, you're right I do want the long path, just haven't been able to try it out yet.  I'll get back to you and jkr later.
0
 

Author Comment

by:marcus78
ID: 7015443
Crius, GetLongPathName() isn't supported in NT 4.0, so I couldn't use that.  Thanks for pointing it out though.

jkr, while GetShortPathName was the opposite of what I needed, it put me on the right track to end up using FindFirstFile.  I was able to use this to determine the long path in NT 4.0.  Thanks for your help!

Marcus
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…
Suggested Courses

623 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