Windows API Guide: GetFileTime Function


Declare Function GetShortPathName Lib "kernel32.dll" Alias "GetShortPathNameA" (ByVal lpszLongPath As String, ByVal lpszShortPath As String, ByVal cchBuffer As Long) As Long

Platforms

  • Windows 95: Supported.
  • Windows 98: Supported.
  • Windows NT: Requires Windows NT 3.5 or later.
  • Windows 2000: Supported.
  • Windows CE: Not Supported.

Description & Usage

GetShortPathName converts a long filename into the old-style 8.3 filenames. Although Windows allows the use of long filenames, DOS programs and 16-bit Windows programs must use the 8.3 equivalent. For example, the equivalent of ReallyLongFile.txt could be REALLY~1.TXT.

Return Value

If successful, the function returns the length of the string copied into lpszShortPath, not including the terminating null character. If an error occured, the function returns 0 (use GetLastError to get the error code).

Visual Basic-Specific Issues

None.

Parameters

lpszLongPath
The complete long path and filename to convert.
lpszShortPath
Receives the 8.3 form of the filename, terminated by a null character. This string must already be sufficiently large to receive the 8.3 filename.
cchBuffer
The length of the string passed as lpszShortPath.

Example

' This code is licensed according to the terms and conditions listed here. ' Declarations and such needed for the example: ' (Copy them to the (declarations) section of a module.) Public Declare Function GetShortPathName Lib "kernel32.dll" Alias "GetShortPathNameA" _ (ByVal lpszLongPath As String, ByVal lpszShortPath As String, ByVal cchBuffer _ As Long) As Long ' Find the short filename equivalent of "C:\My Documents\ReadMeFirst.txt" Private Sub Command1_Click() Dim shortname As String  ' receives short-filename equivalent Dim slength As Long  ' receives length of short-filename equivalent ' Make room in the buffer to receive the 8.3 form of the filename. shortname = Space(256) ' Get the 8.3 form of the filename specified. slength = GetShortPathName("C:\My Documents\ReadMeFirst.txt", shortname, 256) ' Remove the trailing null and display the result. shortname = Left(shortname, slength) Debug.Print "Equivalent: "; shortname End Sub

See Also

GetFullPathName

Category

Files

Go back to the alphabetical Function listing.
Go back to the Reference section index.


Last Modified: July 4, 2000
This page is copyright © 2000 Paul Kuliniewicz. Copyright Information Revised October 29, 2000
Go back to the Windows API Guide home page.
E-mail: vbapi@vbapi.com Send Encrypted E-Mail
This page is at http://www.vbapi.com/ref/g/getshortpathname.html



Windows API Guide
Windows API Guide - Reference - Volume 1: Version 3.0 For the MS-DOS and PC-DOS Operating Systems
ISBN: B001V0KQIY
EAN: N/A
Year: 1998
Pages: 610

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net