HOWTO: Invoke the Shell's File Properties Dialog Box Q179377 SHELLEXECUTEINFO sei; ZeroMemory(&sei,sizeof(sei));
sei.cbSize = sizeof(sei);
sei.lpFile = szPathOfFileToLaunchPropertiesOf;
sei.lpVerb = "properties";
sei.fMask = SEE_MASK_INVOKEIDLIST;
ShellExecuteEx(&sei);
sei.cbSize = sizeof(sei);
sei.lpFile = szPathOfFileToLaunchPropertiesOf;
sei.lpVerb = "properties";
sei.fMask = SEE_MASK_INVOKEIDLIST;
ShellExecuteEx(&sei);
解决方案 »
- 高分求 VB操作文本文件的代码
- 关于SQL Server中存储日期时间
- 支持VB6,来这里签名吧。
- 如何让Sizeable的窗体不在任务栏上显示
- 紧急求助+100分,蔡鸟级网络编程问题,不要笼统的回答我呀~:)
- 用open能打开非DOS 8.3格式的文件名吗?
- 请教了,我用vb的打包向导做出来的安装程序通常都很大,有10几M,我对vb不是很懂。这样是正常的么?
- 用什么方法才能播放rm的影片
- 帮帮忙!!!如何用WINSOCK下载.txt文件到指定目录!!!
- 如何做到用VB、VFP或ACCESS编写的程序不用安装而直接运行在光盘上
- 做一个DLL,里面能否有想析构函数一样的东西对一些私有变量初始话?
- 请问spy++是什么软件在那有得下载有什么用?
Dim wordApp As New Word.Application
Dim wordDoc As New Word.Document
wordApp.Documents.Open "e:\test.doc"With wordApp.ActiveDocument
Print .Words.Count
Print .Paragraphs.Count
Print .ActiveTheme
End With
wordApp.ActiveDocument.Close
Set wordApp = Nothing
祝你好运!
Alias "FindFirstFileA" _
(ByVal lpFileName As String, _
lpFindFileData As WIN32_FIND_DATA) As Long
Public Declare Function FindNextFile Lib "kernel32" _
Alias "FindNextFileA" _
(ByVal hFindFile As Long, _
lpFindFileData As WIN32_FIND_DATA) As Long
Public Declare Function FindClose Lib "kernel32" _
(ByVal hFindFile As Long) As LongPublic Const MAX_PATH = 260Public Type FILETIME
dwLowDateTime As Long
dwHighDateTime As Long
End TypePublic Type WIN32_FIND_DATA
dwFileAttributes As Long
ftCreationTime As FILETIME
ftLastAccessTime As FILETIME
ftLastWriteTime As FILETIME
nFileSizeHigh As Long
nFileSizeLow As Long
dwReserved0 As Long
dwReserved1 As Long
cFileName As String * MAX_PATH
cAlternate As String * 14
End TypeType 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 'Optional
lpClass As String 'Optional
hkeyClass As Long 'Optional
dwHotKey As Long 'Optional
hIcon As Long 'Optional
hProcess As Long 'Optional
End TypePublic Const SEE_MASK_INVOKEIDLIST = &HC
Public Const SEE_MASK_NOCLOSEPROCESS = &H40
Public Const SEE_MASK_FLAG_NO_UI = &H400Declare Function ShellExecuteEx Lib "shell32" _
Alias "ShellExecuteEx" _
(SEI As SHELLEXECUTEINFO) As Long
'以下在Form里面
Private Sub Form_Load()
Me.Move (Screen.Width - Me.Width) \ 2, (Screen.Height - Me.Height) \ 2
Command1.Caption = "Drive"
Command2.Caption = "Folder"
Command3.Caption = "File"
Command4.Caption = "End"
LoadFolderInfo
End Sub
Private Sub Command4_Click()
Unload Me
End Sub
Private Sub Command3_Click()
'pass the selected item. Bracketing the list item assures
'that the text is passed, rather than the list property.
ShowProperties (FilesList.List(FilesList.ListIndex))
End Sub
Private Sub Command2_Click()
ShowProperties (FolderList.List(FolderList.ListIndex))
End Sub
Private Sub Command1_Click()
ShowProperties (Drive1.List(Drive1.ListIndex))
End Sub
Private Sub Drive1_Change() 'trap a drive not ready error
On Local Error GoTo Drive1_Error 'change to the selected drive
ChDrive Drive1.Drive 'get the info
LoadFolderInfo
Exit Sub
Drive1_Error: MsgBox "The selected drive is not ready.", _
vbCritical, "File and Property Demo"
End Sub
Private Sub FilesList_Click()
'only enable the properies button if both an item is
'selected, and that item is not the 'no files' message
Command3.Enabled = (FilesList.ListIndex > -1) And _
(FilesList.List(FilesList.ListIndex)) <> ""
End Sub
Private Sub FilesList_DblClick() 'add double-click fuctionality
ShowProperties (FilesList.List(FilesList.ListIndex))
End Sub
Private Sub FolderList_Click()
Command2.Enabled = (FolderList.ListIndex > -1)
End Sub
Private Sub FolderList_DblClick() 'add double-click fuctionality
Dim newPath As String
newPath = Trim$(FolderList.List(FolderList.ListIndex))
'Required to validate the path
If Right$(CurDir, 1) <> "\" Then
ChDir CurDir + "\" + newPath
Else: ChDir CurDir + newPath
End If
'Get items for the new folder
LoadFolderInfo
End Sub
Private Function TrimNull(item As String)
'Return a string without the chr$(0) terminator.
Dim pos As Integer
pos = InStr(item, Chr$(0))
If pos Then
TrimNull = Left$(item, pos - 1)
Else: TrimNull = item
End If
End FunctionPrivate Sub ShowProperties(filename As String)
Dim SEI As SHELLEXECUTEINFO
With SEI
.cbSize = Len(SEI)
.fMask = SEE_MASK_NOCLOSEPROCESS Or _
SEE_MASK_INVOKEIDLIST Or _
SEE_MASK_FLAG_NO_UI
.hwnd = Me.hwnd
.lpVerb = "properties"
.lpFile = filename
.lpParameters = vbNullChar
.lpDirectory = vbNullChar
.nShow = 0
.hInstApp = 0
.lpIDList = 0
End With
Call ShellExecuteEx(SEI)
End Sub
Private Sub LoadFolderInfo()
'Display the contents of a drive/folder.
Dim hFile As Long
Dim fname As String
Dim WFD As WIN32_FIND_DATA
lbCurrPath.Caption = " Reading files and directories...."
FilesList.Clear
FolderList.Clear
Command3.Enabled = False
Command2.Enabled = False
'Get the first file in the directory (it will usually return ".")
hFile = FindFirstFile("*.*" & Chr$(0), WFD)
'If nothing returned, bail out.
If hFile < 0 Then
Exit Sub
Do
'list the directories in the FolderList.
If (WFD.dwFileAttributes And vbDirectory) Then
'strip the trailing chr$(0) and add to the folder list.
FolderList.AddItem TrimNull(WFD.cFileName)
Else
'strip the trailing chr$(0) and add to the file list.
FilesList.AddItem TrimNull(WFD.cFileName)
End If
Loop While FindNextFile(hFile, WFD)
'Close the search handle
Call FindClose(hFile)
'update both the current path label and the filelist
If FilesList.ListCount = 0 Then FilesList.AddItem ""
lbCurrPath.Caption = CurDir
End Sub