比如快捷方式,就可以判断这个文件是快捷方式,如果是TXT就可以判断是一个文本文档

解决方案 »

  1.   


    if 扩展名=".LNK" then
       文件是快捷方式
    elseif 扩展名=".LNK" then
       是一个文本文档
    endif
      

  2.   

    Option ExplicitPrivate Declare Function RegQueryValue Lib "advapi32.dll" Alias "RegQueryValueA" (ByVal hKey As Long, ByVal lpSubKey As String, ByVal lpValue As String, lpcbValue As Long) As Long
    Private Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) As LongPrivate Const REG_SZ = 1
    Private Const HKEY_CLASSES_ROOT = &H80000000Private Sub Form_Load()
        Text1.Text = ".bas"
    End SubPrivate Sub Command1_Click()
        MsgBox GetFileInfo(Text1.Text)
    End Sub
    Private Function GetFileInfo(ByVal File As String) As String
        Dim hKey As Long
        Dim S As String
        S = String(255, Chr(0))
        If RegQueryValue(HKEY_CLASSES_ROOT, File, S, Len(S)) <> 0 Then Exit Function
        GetFileInfo = Left(S, InStr(S, Chr(0)) - 1)
        RegCloseKey hKey
    End Function