获得Win9X下文件的短文件名

2008-04-09 04:42:45来源:互联网 阅读 ()

新老客户大回馈,云服务器低至5折

步骤一

在Form中加入一个FileListBox,一个DirListBox,一个Label.

步骤二

在Form中加入以下代码:

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

Private Sub Dir1_Change()
File1 = Dir1.Path
End Sub

Private Sub Drive1_Change()
Dir1 = Drive1
End Sub

Private Sub File1_Click()
Label1.Caption = GetShortFileName(Dir1 & "\" & File1)
End Sub

Public Function GetShortFileName(ByVal FileName As String) As String
'converts a long file and path name to old DOS format
'PARAMETERS
' FileName = the path or filename to convert
'RETURNS
' String = the DOS compatible name for that particular FileName

Dim rc As Long
Dim ShortPath As String
Const PATH_LEN& = 164

'get the short filename
ShortPath = String$(PATH_LEN 1, 0)
rc = GetShortPathName(FileName, ShortPath, PATH_LEN)
GetShortFileName = Left$(ShortPath, rc)
End Function

标签:

版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有

上一篇:什么是Windows API

下一篇:调用API函数设计ABOUT窗口

热门词条
热门标签