一些有用的Windows Shell对象库(已经封装为用户对象)

来源:互联网 发布:软件项目测试方案 编辑:程序博客网 时间:2024/04/29 02:35

下载:www.pdriver.com/pb02/11/6shell.zip (size:11kb) (pb 6.x格式)

说明:陶清
本程序是老外所写,有封装好的用户对象及源代码,但没有写调用例程,函数的注解和参数说明还比较详细(英文),自己花点时间写点调用例程吧

1.有move/copy/delete 多个文件(包括目录和子目录)功能
2.因为使用标准Windows Shell方法,所以结果和“资源管理器”效果一样,即有动画提示,有重名文件也同样会提示是否覆盖等
3.可以浏览(目录/打印机/网上邻居) <--这一点本站已经有许多对象可以做到一点,所有的方法都是一致的。
4.可以格式化磁盘。(同样是和Windows出现的效果一样)

程序中用到了下面这些API函数

=== Shell functions
Subroutine SHAddToRecentDocs( ulong uFlags, Ref String pV ) Library "shell32.dll"
Function long SHBrowseForFolder( Ref BROWSEINFO lpBi ) Library "shell32.dll"
Function boolean SHGetPathFromIDList( long pIDL, Ref String pszPath  ) Library "shell32.dll" Alias For "SHGetPathFromIDListA"
Function long SHFileOperation( Ref SHFILEOPSTRUCT lpFileOp ) Library "shell32.dll" Alias For "SHFileOperationA"
Function long SHGetSpecialFolderLocation( long hwndOwner, long nFolder, Ref Long ppidl ) Library "shell32.dll"
Function long SHFormatDrive( ulong hWnd, ulong iDrive, ulong iCapacity, ulong iType ) Library "shell32.dll"

=== Memory functions
Function long RtlMoveMemory(REF Char Destination[], long Source, long Size) library "kernel32"
Function long RtlMoveMemory(long Destination, REF Char Source[], long Size) library "kernel32"
Function long LocalAlloc(long Flags, long Bytes) library "kernel32"
Function long LocalFree(long MemHandle) library "kernel32"

转载:http://www.pdriver.com/display.asp?key_id=1180

 

==========================================================

Instance Variables

// MAX_PATH constant for file operations
Private constant long MAX_PATH = 260

// SHBrowseForFolder constants
Private:
constant ulong BIF_RETURNONLYFSDIRS = 1 // Browse for directory
constant ulong BIF_DONTGOBELOWDOMAIN = 2 // For starting the Find Computer
constant ulong BIF_STATUSTEXT  = 4
constant ulong BIF_RETURNFSANCESTORS = 8
constant ulong BIF_EDITBOX   = 16
constant ulong BIF_BROWSEFORCOMPUTER = 4096 // Browse for computer
constant ulong BIF_BROWSEFORPRINTER = 8192 // Browse for printers
constant ulong BIF_BROWSEINCLUDEFILES = 16384 // Browse for everything

// SHAddToRecentDocs constants
Private:
constant ulong SHARD_PIDL  = 1
constant ulong SHARD_PATH = 2

// File Operation constants
Private:
constant ulong FO_MOVE  = 1
constant ulong FO_COPY  = 2
constant ulong FO_DELETE  = 3
constant ulong FO_RENAME  = 4

// File Operation flags
Private:
constant ulong FOF_MULTIDESTFILES  = 1 // 0x0001
constant ulong FOF_CONFIRMMOUSE  = 2 // 0x0002
constant ulong FOF_SILENT   = 4 // 0x0004
constant ulong FOF_RENAMEONCOLLISION = 8 // 0x0008
constant ulong FOF_NOCONFIRMATION = 16 // 0x0010
constant ulong FOF_WANTMAPPINGHANDLE = 32 // 0x0020
constant ulong FOF_ALLOWUNDO  = 64 // 0x0040
constant ulong FOF_FILESONLY  = 128 // 0x0080
constant ulong FOF_SIMPLEPROGRESS = 256 // 0x0100
constant ulong FOF_NOCONFIRMMKDIR = 512 // 0x0200
constant ulong FOF_NOERRORUI  = 1024 // 0x0400

// SHGetSpecialFolderLocation constants
Public:
constant ulong CSIDL_DESKTOP  = 0 // 0x0000
constant ulong CSIDL_PROGRAMS  = 2 // 0x0002
constant ulong CSIDL_CONTROLS  = 3 // 0x0003
constant ulong CSIDL_PRINTERS  = 4 // 0x0004
constant ulong CSIDL_PERSONAL  = 5 // 0x0005
constant ulong CSIDL_FAVORITES  = 6 // 0x0006
constant ulong CSIDL_STARTUP  = 7 // 0x0007
constant ulong CSIDL_RECENT  = 8 // 0x0008
constant ulong CSIDL_SENDTO  = 9 // 0x0009
constant ulong CSIDL_BITBUCKET  = 10 // 0x000a
constant ulong CSIDL_STARTMENU  = 11 // 0x000b
constant ulong CSIDL_DESKTOPDIRECTORY = 16 // 0x0010
constant ulong CSIDL_DRIVES  = 17 // 0x0011
constant ulong CSIDL_NETWORK  = 18 // 0x0012
constant ulong CSIDL_NETHOOD  = 19 // 0x0013
constant ulong CSIDL_FONTS  = 20 // 0x0014
constant ulong CSIDL_TEMPLATES  = 21 // 0x0015
constant ulong CSIDL_COMMON_STARTMENU = 22 // 0x0016
constant ulong CSIDL_COMMON_PROGRAMS = 23 // 0X0017
constant ulong CSIDL_COMMON_STARTUP = 24 // 0x0018
constant ulong CSIDL_COMMON_DESKTOPDIRECTORY = 25 // 0x0019
constant ulong CSIDL_APPDATA  = 26 // 0x001a
constant ulong CSIDL_PRINTHOOD  = 27 // 0x001b

 

Local External Functions

// Shell functions
Subroutine SHAddToRecentDocs( ulong uFlags, Ref String pV ) Library "shell32.dll"
Function long SHBrowseForFolder( Ref BROWSEINFO lpBi ) Library "shell32.dll"
Function boolean SHGetPathFromIDList( long pIDL, Ref String pszPath  ) Library "shell32.dll" Alias For "SHGetPathFromIDListA"
Function long SHFileOperation( Ref SHFILEOPSTRUCT lpFileOp ) Library "shell32.dll" Alias For "SHFileOperationA"
Function long SHGetSpecialFolderLocation( long hwndOwner, long nFolder, Ref Long ppidl ) Library "shell32.dll"
Function long SHFormatDrive( ulong hWnd, ulong iDrive, ulong iCapacity, ulong iType ) Library "shell32.dll"

// Memory functions
Function long RtlMoveMemory(REF Char Destination[], long Source, long Size) library "kernel32"
Function long RtlMoveMemory(long Destination, REF Char Source[], long Size) library "kernel32"
Function long LocalAlloc(long Flags, long Bytes) library "kernel32"
Function long LocalFree(long MemHandle) library "kernel32"

原创粉丝点击