新建From1(窗体),新建Command1(按钮CommandButton),代码:
Private Sub Command1_Click()
Call s_OpenFileAttribute(App.Path & "\Form1.frm")
End Sub
新建模块 modOpenFileAttribute.bas,代码:
Option Explicit
Private Const SW_SHOW = 5
Private Const SEE_MASK_INVOKEIDLIST = &HC
Private Type SHELLEXECUTEINFO
cbSize As Long
fMask As Long
Hwnd As Long
lpVerb As String
lpFile As String
lpParameters As String
lpDirectory As String
nShow As Long
hInstApp As Long
lpIDList As Long
lpClass As String
hkeyClass As Long
dwHotKey As Long
hIcon As Long
hProcess As Long
End Type
Private Declare Function ShellExecuteEx Lib "shell32.dll" (ByRef s As SHELLEXECUTEINFO) As Long
Public Sub s_OpenFileAttribute(ByVal strPath As String)
Dim shInfo As SHELLEXECUTEINFO
With shInfo
.cbSize = LenB(shInfo)
.lpFile = strPath
.nShow = SW_SHOW
.fMask = SEE_MASK_INVOKEIDLIST
.lpVerb = "properties"
End With
ShellExecuteEx shInfo
End Sub
可以直接打开文件属性面板。