Solved

How to find the DOS name of a file?

Posted on 1998-09-20
4
132 Views
Last Modified: 2010-04-30
How do I find the MS-DOS filename of a file?
0
Comment
Question by:Olli083097
4 Comments
 
LVL 4

Expert Comment

by:mcix
Comment Utility
Could you please clarify your question?
0
 
LVL 3

Expert Comment

by:a111a111a111
Comment Utility
Give example please!
0
 
LVL 6

Accepted Solution

by:
clifABB earned 50 total points
Comment Utility
Add the following code to the declarations section:
Private Declare Function GetShortPathName Lib "kernel32" Alias "GetShortPathNameA" (ByVal lpszLongPath As String, ByVal lpszShortPath As String, ByVal cchBuffer As Long) As Long

The Add the following subroutine:
Private Function GetShortName(ByVal sLongFileName As String) As String
  Dim lRetVal As Long
  Dim sShortPathName As String
  Dim nLen As Integer

  'Set up buffer area for API function call return
  sShortPathName = Space(255)
  nLen = Len(sShortPathName)
 
  'Call the function
  lRetVal = GetShortPathName(sLongFileName, sShortPathName, nLen)
  'Strip away unwanted characters.
  GetShortName = Left(sShortPathName, lRetVal)
End Function

You can then call this function passing the long filename and it will return the short filename.
0
 

Author Comment

by:Olli083097
Comment Utility
Thanx!
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

762 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

6 Experts available now in Live!

Get 1:1 Help Now