'在窗体上放置一个FileListBox控件和一个Label控件。把下列代码复制
'进去。Label控件里显示的就是桌面的快捷方式的个数
'FileListBox里显示的是你桌面上的所有的快捷方式的名称(快捷方式
’的扩展名(后缀)是*.lnk)
'程序经过测试,可以运行
Private Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" (ByVal lpbuffer As String, nSize As Long) As Long
Dim S As String
Private Sub Form_Load()
File1.Pattern = "*.lnk"
Dim sBuffer As String
Dim lSize As Long
sBuffer = Space$(255)
lSize = Len(sBuffer)
Call GetUserName(sBuffer, lSize)
Dim A As String
If lSize > 0 Then
A = Left$(sBuffer, lSize)
A = Left(A, Len(A) - 1)
S = "c:\Documents and settings\" & A & "\桌面\"
Else
A = vbNullString
End If
File1.Path = S
Label1.Caption = File1.ListCount
End Sub