当前位置:首页 > 编程学习 > VB.NET 用ShellExecuteEx 打开系统文件属性对话框 模块

VB.NET 用ShellExecuteEx 打开系统文件属性对话框 模块

编程学习2007-06-0961120
'
' VB.NET 调用系统文件属性对话框模块
'
' by: Apull
' QQ:374237545
' http://www.apull.net
' 2007-6-9
'
'
Imports System.Runtime.InteropServices
   
Module SHFileCtrl
   
#Region "API's"
   
'------------------------------
'查看文件属性API
Public Structure SHELLEXECUTEINFO
Dim cbSize As Integer
Dim fMask As Integer
Dim hwnd As IntPtr
Dim lpVerb As String
Dim lpFile As String
Dim lpParameters As String
Dim lpDirectory As String
Dim nShow As Integer
Dim hInstApp As IntPtr
Dim lpIDList As IntPtr
Dim lpClass As String
Dim hkeyClass As IntPtr
Dim dwHotKey As Integer
Dim hIcon As IntPtr
Dim hProcess As IntPtr
End Structure
    
' 显示方式
'Private Const SW_HIDE = 0
'Private Const SW_SHOWNORMAL = 1
'Private Const SW_SHOWMINIMIZED = 2
'Private Const SW_SHOWMAXIMIZED = 3
'Private Const SW_MAXIMIZE = 3
'Private Const SW_SHOWNOACTIVATE = 4
'Private Const SW_SHOW = 5
'Private Const SW_MINIMIZE = 6
Private Const SW_SHOWMINNOACTIVE = 7
'Private Const SW_SHOWNA = 8
'Private Const SW_RESTORE = 9
   
'
'Private Const SEE_MASK_CLASSKEY = &H3
'Private Const SEE_MASK_CLASSNAME = &H1
'Private Const SEE_MASK_CONNECTNETDRV = &H80
'Private Const SEE_MASK_DOENVSUBST = &H200
'Private Const SEE_MASK_FLAG_DDEWAIT = &H100
Private Const SEE_MASK_FLAG_NO_UI = &H400
'Private Const SEE_MASK_HOTKEY = &H20
'Private Const SEE_MASK_ICON = &H10
'Private Const SEE_MASK_IDLIST = &H4
Private Const SEE_MASK_INVOKEIDLIST = &HC
Private Const SEE_MASK_NOCLOSEPROCESS = &H40
   
Private Declare Function ShellExecuteEx Lib "shell32.dll" (ByRef lpShellInfo As SHELLEXECUTEINFO As Integer
   
#End Region
   
'显示属性对话框
'参数
'hWnd IntPtr 父窗体句柄
'sFile String 要查看属性的文件
'调用:ShowPropertie(Me.Handle, sFile)
Public Sub ShowPropertie(ByVal hWnd As IntPtr, ByVal sFile As String)
   
    Dim sInfo As New SHELLEXECUTEINFO
    Dim iRet As Integer
   
    Try
        With sInfo
            .cbSize = Marshal.SizeOf(sInfo)
            .fMask = SEE_MASK_NOCLOSEPROCESS Or SEE_MASK_INVOKEIDLIST Or SEE_MASK_FLAG_NO_UI
            .hwnd = hWnd
            .lpVerb = "properties"
            .lpFile = sFile
            .lpParameters = ""
            .lpDirectory = vbNullString
            .nShow = SW_SHOWMINNOACTIVE
            .hInstApp = New IntPtr(0)
            .lpIDList = New IntPtr(0)
            .lpClass = vbNullString
            .hkeyClass = New IntPtr(0)
            .dwHotKey = 0
            .hIcon = New IntPtr(0)
            .hProcess = New IntPtr(0)
        End With
   
        iRet = ShellExecuteEx(sInfo)
   
    Catch ex As Exception
        MsgBox(iRet & vbCrLf & Err.ToString)
    End Try
End Sub
   
End Module


扫描二维码推送至手机访问。

版权声明:本文由海阔天空发布,如需转载请注明出处。

本文链接:https://www.apull.net/html/20070609250.html

分享给朋友:

相关文章

SHFileOperation介绍

SHFileOperation介绍

SHFileOperation函数功能描述:文件操作,与 Shell 的动作相同.函数原型:#include<shellapi.h> WINSHELLAPI int WINAPI SHFileOperation(LPSHFILEOPSTRUCT lpFileOp);参数:typedef struct _SHFILEOPSTRUCT { HWND hwnd; //父窗口句柄 UINT wFu...

 C++ string类常用函数

C++ string类常用函数

string类的构造函数:string(const char *s);    //用c字符串s初始化 string(int n,char  c);     //用n个字符c初始化此外,string类还支持默认构造函数和复制构造函数,如string s1;string  s2="hello";都是正确的写法。...

VB连接SQLServer数据库操作代码

VB连接SQLServer数据库操作代码

第一步,在ModConString模块中定义一系列变量'定义一个属性过程反映连接字符串Public Property Get conString() As Variant conString = "data source=.;initial catalog=Sims_four;user End Property'定义一个提供者反映数据库类型Public Property Get conProvide() As Variant co...

用VB类实现文件对话框

用VB类实现文件对话框

用VB类实现文件对话框'类名:ComDlg.cls '作用:文件打开保存对话框 ' ' ' 'By:Apull '2007-5-21 'http://www.apull.net Option Explicit Private Declare Function GetOpenFileName Lib "comdlg32.dll" Alias "GetOpenFileNameA" ( _ pOpenfil...