跟我学VBA,我这里专注VBA,授人以渔。我98年开始,从源码接触VBA已经20余年了,随着年龄的增长,越来越觉得有必要把这项技能传递给需要这项技术的职场人员。希望职场和数据打交道的朋友,都来学习VBA,利用VBA,起码可以提高自己的工作效率,可以有时间多陪陪父母,多陪陪家人,何乐而不为呢?我的教程一共九套,从入门开始一直讲到程序的分发,是学习利用VBA的实用教程。这份API资料是随高级教程赠送的.
这讲我们继续学习64位OfficeAPI声明语句第113讲,这些内容是MS的权威资料,看似枯燥,但对于想学习API函数的朋友是非常有用的。
【分享成果,随喜正能量】中国人熟知的一些话:“谁知盘中餐,粒粒皆辛苦”,以及“半丝半缕,恒念物力维艰”,等等,都是教导年轻人要感恩,因为由于许多人的辛苦,我们才有衣穿,才有饭吃。。
当学员学习到高级阶段,如果引用API,这个资料可以直接查到64位写法。大多数情况下我们是将低版本的程序文件升级到高版本,这时您就不必为如下的错误提示所困扰了:
Declare PtrSafe Function SHFileOperation Lib "shell32.dll" Alias "SHFileOperationA" (lpFileOp As SHFILEOPSTRUCT) As Long
Declare PtrSafe Sub SHFreeNameMappings Lib "shell32.dll" Alias "SHFreeNameMappings" (ByVal hNameMappings As LongPtr)
Type SHNAMEMAPPING
pszOldPath As String
pszNewPath As String
cchOldPath As Long
cchNewPath As Long
End Type
' // End Shell File Operations
' // Begin ShellExecuteEx and family
' ShellExecute() and ShellExecuteEx() error codes
' regular WinExec() codes
Const SE_ERR_FNF = 2 ' file not found
Const SE_ERR_PNF = 3 ' path not found
Const SE_ERR_ACCESSDENIED = 5 ' access denied
Const SE_ERR_OOM = 8 ' out of memory
Const SE_ERR_DLLNOTFOUND = 32
' Note CLASSKEY overrides CLASSNAME
Const SEE_MASK_CLASSNAME = &H1
Const SEE_MASK_CLASSKEY = &H3
' Note INVOKEIDLIST overrides IDLIST
Const SEE_MASK_IDLIST = &H4
Const SEE_MASK_INVOKEIDLIST = &HC
Const SEE_MASK_ICON = &H10
Const SEE_MASK_HOTKEY = &H20
Const SEE_MASK_NOCLOSEPROCESS = &H40
Const SEE_MASK_CONNECTNETDRV = &H80
Const SEE_MASK_FLAG_DDEWAIT = &H100
Const SEE_MASK_DOENVSUBST = &H200
Const SEE_MASK_FLAG_NO_UI = &H400
Type SHELLEXECUTEINFO
cbSize As Long
fMask As Long
hwnd As LongPtr
lpVerb As String
lpFile As String
lpParameters As String
lpDirectory As String
nShow As Long
hInstApp As LongPtr
' Optional fields
lpIDList As LongPtr
lpClass As String
hkeyClass As LongPtr
dwHotKey As Long
hIcon As LongPtr
hProcess As LongPtr
End Type
' // End ShellExecuteEx and family
' // Tray notification definitions
Type GUID
Data1 As Long
Data2 As Integer
Data3 As Integer
Data4(0 To 7) As Byte
End Type
Type NOTIFYICONDATA
cbSize As Long
hwnd As LongPtr
uID As Long
uFlags As Long
uCallbackMessage As Long
hIcon As LongPtr
'#if (NTDDI_VERSION >= NTDDI_WIN2K)
szTip(0 To 127) As Byte
dwState As Long
dwStateMask As Long
szInfo(0 To 255) As Byte
uTimeout As Long
szInfoTitle(0 To 63) As Byte
dwInfoFlags As Long
'#endif
'#if (NTDDI_VERSION >= NTDDI_WINXP)
guidItem As GUID
'#endif
'#if (NTDDI_VERSION >= NTDDI_VISTA)
' hBalloonIcon As LongPtr
'#endif
End Type
Const NIM_ADD = &H0
Const NIM_MODIFY = &H1
Const NIM_DELETE = &H2
Const NIF_MESSAGE = &H1
Const NIF_ICON = &H2
Const NIF_TIP = &H4
Declare PtrSafe Function Shell_NotifyIcon Lib "shell32.dll" Alias " Shell_NotifyIconA" (ByVal dwMessage As Long, lpData As NOTIFYICONDATA) As Long
' // End Tray Notification Icons
' // Begin SHGetFileInfo
' * The SHGetFileInfo API provides an easy way to get attributes
' * for a file given a pathname.
' *
' * PARAMETERS
' *
' * pszPath file name to get info about
' * dwFileAttributes file attribs, only used with SHGFI_USEFILEATTRIBUTES
' * psfi place to return file info
' * cbFileInfo size of structure
' * uFlags flags
' *
' * RETURN
' * TRUE if things worked
' */
Type SHFILEINFO
hIcon As LongPtr ' out: icon
iIcon As Long ' out: icon index
dwAttributes As Long ' out: SFGAO_ flags
szDisplayName(0 To MAX_PATH - 1) As Byte ' out: display name (or path)
szTypeName(0 To 79) As Byte ' out: type name
End Type
Const SHGFI_ICON = &H100 ' get icon
Const SHGFI_DISPLAYNAME = &H200 ' get display name
Const SHGFI_TYPENAME = &H400 ' get type name
Const SHGFI_ATTRIBUTES = &H800 ' get attributes
Const SHGFI_ICONLOCATION = &H1000 ' get icon location
Const SHGFI_EXETYPE = &H2000 ' return exe type
Const SHGFI_SYSICONINDEX = &H4000 ' get system icon index
Const SHGFI_LINKOVERLAY = &H8000& ' put a link overlay on icon
Const SHGFI_SELECTED = &H10000 ' show icon in selected state
Const SHGFI_LARGEICON = &H0 ' get large icon
Const SHGFI_SMALLICON = &H1 ' get small icon
Const SHGFI_OPENICON = &H2 ' get open icon
Const SHGFI_SHELLICONSIZE = &H4 ' get shell size icon
Const SHGFI_PIDL = &H8 ' pszPath is a pidl
Const SHGFI_USEFILEATTRIBUTES = &H10 ' use passed dwFileAttribute
Declare PtrSafe Function SHGetFileInfo Lib "shell32.dll" Alias "SHGetFileInfoA" (ByVal pszPath As String, ByVal dwFileAttributes As Long, psfi As SHFILEINFO, ByVal cbFileInfo As Long, ByVal uFlags As Long) As LongPtr
Declare PtrSafe Function SHGetNewLinkInfo Lib "shell32.dll" Alias "SHGetNewLinkInfoA" (ByVal pszLinkto As String, ByVal pszDir As String, ByVal pszName As String, pfMustCopy As Long, ByVal uFlags As Long) As Long
Const SHGNLI_PIDL = &H1 ' pszLinkTo is a pidl
Const SHGNLI_PREFIXNAME = &H2 ' Make name "Shortcut to xxx"
' // End SHGetFileInfo
' Copyright (C) 1993 - 1995 Microsoft Corporation
' Module Name:
' winperf.h
' Abstract:
我20多年的VBA实践经验,全部浓缩在下面的各个教程中: