|
-
Nov 10th, 2000, 06:43 PM
#1
Thread Starter
Junior Member
I'm trying to get a short path name using the api call. This is a Win2k machine, either Datacenter or Advanced Server, is there a different API i could use?
Code:
Private Declare Function GetShortPathName Lib "kernel32" Alias _
"GetShortPathNameA" (ByVal lpszLongPath As String, ByVal _
lpszShortPath As String, ByVal lBuffer As Long) As Long
Public Function GetShortPath(strFileName As String) As String
Dim lngRes As Long
Dim strPath As String
strPath = String$(165, 0)
lngRes = GetShortPathName(strFileName, strPath, 164)
GetShortPath = Left$(strPath, lngRes)
End Function
It's in a module, then i just call
MsgBox GetShortPath("C:\Program Files\TPlatC\")
When i step through the program the api call just doesn't return anything. Can anyone help?
-
Nov 10th, 2000, 06:54 PM
#2
Thread Starter
Junior Member
Actually, it looks like the problem I'm having is that I'm trying to convert a path that does not exist on this machine.
-
Nov 10th, 2000, 07:00 PM
#3
_______
<?>
'the filepath must exist
Code:
'bas module code
Option Explicit
Public Declare Function GetShortPathName Lib _
"kernel32.dll" Alias "GetShortPathNameA" _
(ByVal lpszLongPath As String, ByVal lpszShortPath As String, _
ByVal cchBuffer As Long) As Long
'Form Code
Option Explicit
' 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.
'the file must exist for the api to do it's stuff
slength = GetShortPathName("C:\ab\needtodosomework.txt", shortname, 256)
' Remove the trailing null and display the result.
shortname = Left(shortname, slength)
MsgBox shortname
End Sub
"A myth is not the succession of individual images,
but an integerated meaningful entity,
reflecting a distinct aspect of the real world."
___ Adolf Jensen
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|