Solved

Long name from DOS short name

Posted on 2002-05-16
6
217 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
Independent Software Vendors: 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!

 
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

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

Title # Comments Views Activity
post4 challenge 28 123
scoreUp challenge 14 74
sumHeights  challenge 17 83
Excel file not created as expected 7 111
Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
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.
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.
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

710 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