【分享成果,随喜正能量】你要做的是,果断拒绝那些给你制造不安的人,远离那些让你经常陷入负面情绪的人,失去他们,是你幸福的开始。。
跟我学VBA,我这里专注VBA, 授人以渔。我98年开始,从源码接触VBA已经20余年了,随着年龄的增长,越来越觉得有必要把这项技能传递给需要这项技术的职场人员。希望职场和数据打交道的朋友,都来学习VBA,利用VBA,起码可以提高自己的工作效率,可以有时间多陪陪父母,多陪陪家人,何乐而不为呢?我的教程一共九套,从入门开始一直讲到程序的分发,是学习利用VBA的实用教程。这份API资料是随高级教程赠送的.
这讲我们继续学习64位Office API声明语句第109讲,这些内容是MS的权威资料,看似枯燥,但对于想学习API函数的朋友是非常有用的。
当学员学习到高级阶段,如果引用API,这个资料可以直接查到64位写法。大多数情况下我们是将低版本的程序文件升级到高版本,这时您就不必为如下的错误提示所困扰了:
' The divisor for a sample, used with the previous counter to form a
' sampled %. You must check for >0 before dividing by this! This
' counter will directly follow the numerator counter. It should not
' be displayed to the user.
Const PERF_SAMPLE_BASE = (PERF_SIZE_DWORD Or PERF_TYPE_COUNTER Or PERF_COUNTER_BASE Or PERF_DISPLAY_NOSHOW Or &H1) ' for compatibility with pre-beta versions
' A timer which, when divided by an average base, produces a time
' in seconds which is the average time of some operation. This
' timer times total operations, and the base is the number of opera-
' tions. Display Suffix: "sec"
Const PERF_AVERAGE_TIMER = (PERF_SIZE_DWORD Or PERF_TYPE_COUNTER Or PERF_COUNTER_FRACTION Or PERF_DISPLAY_SECONDS)
' Used as the denominator in the computation of time or count
' averages. Must directly follow the numerator counter. Not dis-
' played to the user.
Const PERF_AVERAGE_BASE = (PERF_SIZE_DWORD Or PERF_TYPE_COUNTER Or PERF_COUNTER_BASE Or PERF_DISPLAY_NOSHOW Or &H2) ' for compatibility with pre-beta versions
' A bulk count which, when divided (typically) by the number of
' operations, gives (typically) the number of bytes per operation.
' No Display Suffix.
Const PERF_AVERAGE_BULK = (PERF_SIZE_LARGE Or PERF_TYPE_COUNTER Or PERF_COUNTER_FRACTION Or PERF_DISPLAY_NOSHOW)
' 64-bit Timer in 100 nsec units. Display delta divided by
' delta time. Display suffix: "%"
Const PERF_100NSEC_TIMER = (PERF_SIZE_LARGE Or PERF_TYPE_COUNTER Or PERF_COUNTER_RATE Or PERF_TIMER_100NS Or PERF_DELTA_COUNTER Or PERF_DISPLAY_PERCENT)
' 64-bit Timer inverse (e.g., idle is measured, but display busy As Integer)
' Display 100 - delta divided by delta time. Display suffix: "%"
Const PERF_100NSEC_TIMER_INV = (PERF_SIZE_LARGE Or PERF_TYPE_COUNTER Or PERF_COUNTER_RATE Or PERF_TIMER_100NS Or PERF_DELTA_COUNTER Or PERF_INVERSE_COUNTER Or PERF_DISPLAY_PERCENT)
' 64-bit Timer. Divide delta by delta time. Display suffix: "%"
' Timer for multiple instances, so result can exceed 100%.
Const PERF_COUNTER_MULTI_TIMER = (PERF_SIZE_LARGE Or PERF_TYPE_COUNTER Or PERF_COUNTER_RATE Or PERF_DELTA_COUNTER Or PERF_TIMER_TICK Or PERF_MULTI_COUNTER Or PERF_DISPLAY_PERCENT)
' 64-bit Timer inverse (e.g., idle is measured, but display busy As Integer)
' Display 100 _MULTI_BASE - delta divided by delta time.
' Display suffix: "%" Timer for multiple instances, so result
' can exceed 100%. Followed by a counter of type _MULTI_BASE.
Const PERF_COUNTER_MULTI_TIMER_INV = (PERF_SIZE_LARGE Or PERF_TYPE_COUNTER Or PERF_COUNTER_RATE Or PERF_DELTA_COUNTER Or PERF_MULTI_COUNTER Or PERF_TIMER_TICK Or PERF_INVERSE_COUNTER Or PERF_DISPLAY_PERCENT)
' Number of instances to which the preceding _MULTI_..._INV counter
' applies. Used as a factor to get the percentage.
Const PERF_COUNTER_MULTI_BASE = (PERF_SIZE_LARGE Or PERF_TYPE_COUNTER Or PERF_COUNTER_BASE Or PERF_MULTI_COUNTER Or PERF_DISPLAY_NOSHOW)
' 64-bit Timer in 100 nsec units. Display delta divided by delta time.
' Display suffix: "%" Timer for multiple instances, so result can exceed 100%.
Const PERF_100NSEC_MULTI_TIMER = (PERF_SIZE_LARGE Or PERF_TYPE_COUNTER Or PERF_DELTA_COUNTER Or PERF_COUNTER_RATE Or PERF_TIMER_100NS Or PERF_MULTI_COUNTER Or PERF_DISPLAY_PERCENT)
' 64-bit Timer inverse (e.g., idle is measured, but display busy As Integer)
' Display 100 _MULTI_BASE - delta divided by delta time.
' Display suffix: "%" Timer for multiple instances, so result
' can exceed 100%. Followed by a counter of type _MULTI_BASE.
Const PERF_100NSEC_MULTI_TIMER_INV = (PERF_SIZE_LARGE Or PERF_TYPE_COUNTER Or PERF_DELTA_COUNTER Or PERF_COUNTER_RATE Or PERF_TIMER_100NS Or PERF_MULTI_COUNTER Or PERF_INVERSE_COUNTER Or PERF_DISPLAY_PERCENT)
' Indicates the data is a fraction of the following counter which
' should not be time averaged on display (such as free space over
' total space.) Display as is. Display the quotient as "%".
Const PERF_RAW_FRACTION = (PERF_SIZE_DWORD Or PERF_TYPE_COUNTER Or PERF_COUNTER_FRACTION Or PERF_DISPLAY_PERCENT)
' Indicates the data is a base for the preceding counter which should
' not be time averaged on display (such as free space over total space.)
Const PERF_RAW_BASE = (PERF_SIZE_DWORD Or PERF_TYPE_COUNTER Or PERF_COUNTER_BASE Or PERF_DISPLAY_NOSHOW Or &H3) ' for compatibility with pre-beta versions
' The data collected in this counter is actually the start time of the
' item being measured. For display, this data is subtracted from the
' sample time to yield the elapsed time as the difference between the two.
' In the definition below, the PerfTime field of the Object contains
' the sample time as indicated by the PERF_OBJECT_TIMER bit and the
' difference is scaled by the PerfFreq of the Object to convert the time
' units into seconds.
Const PERF_ELAPSED_TIME = (PERF_SIZE_LARGE Or PERF_TYPE_COUNTER Or PERF_COUNTER_ELAPSED Or PERF_OBJECT_TIMER Or PERF_DISPLAY_SECONDS)
' The following counter type can be used with the preceding types to
' define a range of values to be displayed in a histogram.
Const PERF_COUNTER_HISTOGRAM_TYPE = &H80000000 ' Counter begins or ends a histogram
' The following are used to determine the level of detail associated
' with the counter. The user will be setting the level of detail
' that should be displayed at any given time.
Const PERF_DETAIL_NOVICE = 100 ' The uninformed can understand it
Const PERF_DETAIL_ADVANCED = 200 ' For the advanced user
Const PERF_DETAIL_EXPERT = 300 ' For the expert user
Const PERF_DETAIL_WIZARD = 400 ' For the system designer
Type PERF_COUNTER_DEFINITION
ByteLength As Long
CounterNameTitleIndex As Long
#If Win64 Then
CounterNameTitle As Long
#Else
CounterNameTitle As String
#End If
CounterHelpTitleIndex As Long
#If Win64 Then
CounterHelpTitle As Long
#Else
CounterHelpTitle As String
#End If
DefaultScale As Long
DetailLevel As Long
CounterType As Long
CounterSize As Long
CounterOffset As Long
End Type
Const PERF_NO_UNIQUE_ID = -1
Type PERF_INSTANCE_DEFINITION
ByteLength As Long
ParentObjectTitleIndex As Long
ParentObjectInstance As Long
UniqueID As Long
NameOffset As Long
NameLength As Long
End Type
Type PERF_COUNTER_BLOCK
ByteLength As Long
End Type
Const CDERR_DIALOGFAILURE = &HFFFF&
Const CDERR_GENERALCODES = &H0
Const CDERR_STRUCTSIZE = &H1
Const CDERR_INITIALIZATION = &H2
Const CDERR_NOTEMPLATE = &H3
Const CDERR_NOHINSTANCE = &H4
Const CDERR_LOADSTRFAILURE = &H5
Const CDERR_FINDRESFAILURE = &H6
Const CDERR_LOADRESFAILURE = &H7
Const CDERR_LOCKRESFAILURE = &H8
Const CDERR_MEMALLOCFAILURE = &H9
Const CDERR_MEMLOCKFAILURE = &HA
Const CDERR_NOHOOK = &HB
Const CDERR_REGISTERMSGFAIL = &HC
Const PDERR_PRINTERCODES = &H1000
Const PDERR_SETUPFAILURE = &H1001
Const PDERR_PARSEFAILURE = &H1002
Const PDERR_RETDEFFAILURE = &H1003
Const PDERR_LOADDRVFAILURE = &H1004
Const PDERR_GETDEVMODEFAIL = &H1005
Const PDERR_INITFAILURE = &H1006
Const PDERR_NODEVICES = &H1007
Const PDERR_NODEFAULTPRN = &H1008
Const PDERR_DNDMMISMATCH = &H1009
Const PDERR_CREATEICFAILURE = &H100A
Const PDERR_PRINTERNOTFOUND = &H100B
Const PDERR_DEFAULTDIFFERENT = &H100C
Const CFERR_CHOOSEFONTCODES = &H2000
Const CFERR_NOFONTS = &H2001
Const CFERR_MAXLESSTHANMIN = &H2002
Const FNERR_FILENAMECODES = &H3000
Const FNERR_SUBCLASSFAILURE = &H3001
Const FNERR_INVALIDFILENAME = &H3002
Const FNERR_BUFFERTOOSMALL = &H3003
Const FRERR_FINDREPLACECODES = &H4000
Const FRERR_BUFFERLENGTHZERO = &H4001
Const CCERR_CHOOSECOLORCODES = &H5000
' Public interface to LZEXP?.LIB
' LZEXPAND error return codes
Const LZERROR_BADINHANDLE = (-1) ' invalid input handle
Const LZERROR_BADOUTHANDLE = (-2) ' invalid output handle
Const LZERROR_READ = (-3) ' corrupt compressed file format
Const LZERROR_WRITE = (-4) ' out of space for output file
Const LZERROR_PUBLICLOC = (-5) ' insufficient memory for LZFile struct
Const LZERROR_GLOBLOCK = (-6) ' bad Global handle
Const LZERROR_BADVALUE = (-7) ' input parameter out of range
Const LZERROR_UNKNOWNALG = (-8) ' compression algorithm not recognized
Declare PtrSafe Function LZCopy Lib "lz32.dll" Alias "LZCopy" (ByVal hfSource As Long, ByVal hfDest As Long) As Long
Declare PtrSafe Function LZInit Lib "lz32.dll" Alias "LZInit" (ByVal hfSrc As Long) As Long
Declare PtrSafe Function GetExpandedName Lib "lz32.dll" Alias "GetExpandedNameA" (ByVal lpszSource As String, ByVal lpszBuffer As String) As Long
Declare PtrSafe Function LZOpenFile Lib "lz32.dll" Alias "LZOpenFileA" (ByVal lpszFile As String, lpOf As OFSTRUCT, ByVal style As Long) As Long
Declare PtrSafe Function LZSeek Lib "lz32.dll" Alias "LZSeek" (ByVal hfFile As Long, ByVal lOffset As Long, ByVal nOrigin As Long) As Long
Declare PtrSafe Function LZRead Lib "lz32.dll" Alias "LZRead" (ByVal hfFile As Long, ByVal lpvBuf As String, ByVal cbread As Long) As Long
Declare PtrSafe Sub LZClose Lib "lz32.dll" Alias "LZClose" (ByVal hfFile As Long)
我20多年的VBA实践经验,全部浓缩在下面的各个教程中: