首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

64位Office API声明语句第108讲

跟我学VBA,我这里专注VBA, 授人以渔。我98年开始,从源码接触VBA已经2余年了,随着年龄的增长,越来越觉得有必要把这项技能传递给需要这项技术的职场人员。希望职场和数据打交道的朋友,都来学习VBA,利用VBA,起码可以提高自己的工作效率,可以有时间多陪陪父母,多陪陪家人,何乐而不为呢?我的教程一共九套,从入门开始一直讲到程序的分发,是学习利用VBA的实用教程。这份API资料是随高级教程赠送的.

这讲我们继续学习64位Office API声明语句第108讲,这些内容是MS的权威资料,看似枯燥,但对于想学习API函数的朋友是非常有用的。

当学员学习到高级阶段,如果引用API,这个资料可以直接查到64位写法。大多数情况下我们是将低版本的程序文件升级到高版本,这时您就不必为如下的错误提示所困扰了:

Declare PtrSafe Function RegisterServiceCtrlHandler Lib "advapi32.dll" Alias "RegisterServiceCtrlHandlerA" (ByVal lpServiceName As String, ByVal lpHandlerProc As LongPtr) As LongPtr

Declare PtrSafe Function SetServiceObjectSecurity Lib "advapi32.dll" Alias "SetServiceObjectSecurity" (ByVal hService As LongPtr, ByVal dwSecurityInformation As Long, lpSecurityDescriptor As Any) As Long

Declare PtrSafe Function SetServiceStatus Lib "advapi32.dll" Alias "SetServiceStatus" (ByVal hServiceStatus As LongPtr, lpServiceStatus As SERVICE_STATUS) As Long

Declare PtrSafe Function StartServiceCtrlDispatcher Lib "advapi32.dll" Alias "StartServiceCtrlDispatcherA" (lpServiceStartTable As SERVICE_TABLE_ENTRY) As Long

Declare PtrSafe Function StartService Lib "advapi32.dll" Alias "StartServiceA" (ByVal hService As LongPtr, ByVal dwNumServiceArgs As Long, ByVal lpServiceArgVectors As LongPtr) As Long

Declare PtrSafe Function UnlockServiceDatabase Lib "advapi32.dll" Alias "UnlockServiceDatabase" (ScLock As Any) As Long

' Section for Performance Monitor data

Const PERF_DATA_VERSION = 1

Const PERF_DATA_REVISION = 1

Type PERF_DATA_BLOCK

Signature(0 To 3) As Integer

LittleEndian As Long

Version As Long

Revision As Long

TotalByteLength As Long

HeaderLength As Long

NumObjectTypes As Long

DefaultObject As Long

SystemTime As SYSTEMTIME

PerfTime As LARGE_INTEGER

PerfFreq As LARGE_INTEGER

PerTime100nSec As LARGE_INTEGER

SystemNameLength As Long

SystemNameOffset As Long

End Type

Type PERF_OBJECT_TYPE

TotalByteLength As Long

DefinitionLength As Long

HeaderLength As Long

ObjectNameTitleIndex As Long

#If Win64 Then

ObjectNameTitle As Long

#Else

ObjectNameTitle As String

#End If

ObjectHelpTitleIndex As Long

#If Win64 Then

ObjectHelpTitle As Long

#Else

ObjectHelpTitle As String

#End If

DetailLevel As Long

NumCounters As Long

DefaultCounter As Long

NumInstances As Long

CodePage As Long

PerfTime As LARGE_INTEGER

PerfFreq As LARGE_INTEGER

End Type

Const PERF_NO_INSTANCES = -1 ' no instances

' The counter type is the "or" of the following values as described below

'

' select one of the following to indicate the counter's data size

Const PERF_SIZE_DWORD = &H0

Const PERF_SIZE_LARGE = &H100

Const PERF_SIZE_ZERO = &H200 ' for Zero Length fields

Const PERF_SIZE_VARIABLE_LEN = &H300 ' length is in CounterLength field of Counter Definition struct

' select one of the following values to indicate the counter field usage

Const PERF_TYPE_NUMBER = &H0 ' a number (not a counter)

Const PERF_TYPE_COUNTER = &H400 ' an increasing numeric value

Const PERF_TYPE_TEXT = &H800 ' a text field

Const PERF_TYPE_ZERO = &HC00 ' displays a zero

' If the PERF_TYPE_NUMBER field was selected, then select one of the

' following to describe the Number

Const PERF_NUMBER_HEX = &H0 ' display as HEX value

Const PERF_NUMBER_DECIMAL = &H10000 ' display as a decimal integer

Const PERF_NUMBER_DEC_1000 = &H20000 ' display as a decimal/1000

'

' If the PERF_TYPE_COUNTER value was selected then select one of the

' following to indicate the type of counter

Const PERF_COUNTER_VALUE = &H0 ' display counter value

Const PERF_COUNTER_RATE = &H10000 ' divide ctr / delta time

Const PERF_COUNTER_FRACTION = &H20000 ' divide ctr / base

Const PERF_COUNTER_BASE = &H30000 ' base value used in fractions

Const PERF_COUNTER_ELAPSED = &H40000 ' subtract counter from current time

Const PERF_COUNTER_QUEUELEN = &H50000 ' Use Queuelen processing func.

Const PERF_COUNTER_HISTOGRAM = &H60000 ' Counter begins or ends a histogram

' If the PERF_TYPE_TEXT value was selected, then select one of the

' following to indicate the type of TEXT data.

Const PERF_TEXT_UNICODE = &H0 ' type of text in text field

Const PERF_TEXT_ASCII = &H10000 ' ASCII using the CodePage field

' Timer SubTypes

Const PERF_TIMER_TICK = &H0 ' use system perf. freq for base

Const PERF_TIMER_100NS = &H100000 ' use 100 NS timer time base units

Const PERF_OBJECT_TIMER = &H200000 ' use the object timer freq

' Any types that have calculations performed can use one or more of

' the following calculation modification flags listed here

Const PERF_DELTA_COUNTER = &H400000 ' compute difference first

Const PERF_DELTA_BASE = &H800000 ' compute base diff as well

Const PERF_INVERSE_COUNTER = &H1000000 ' show as 1.00-value (assumes:

Const PERF_MULTI_COUNTER = &H2000000 ' sum of multiple instances

' Select one of the following values to indicate the display suffix (if any)

Const PERF_DISPLAY_NO_SUFFIX = &H0 ' no suffix

Const PERF_DISPLAY_PER_SEC = &H10000000 ' "/sec"

Const PERF_DISPLAY_PERCENT = &H20000000 ' "%"

Const PERF_DISPLAY_SECONDS = &H30000000 ' "secs"

Const PERF_DISPLAY_NOSHOW = &H40000000 ' value is not displayed

' Predefined counter types

' 32-bit Counter. Divide delta by delta time. Display suffix: "/sec"

Const PERF_COUNTER_COUNTER = (PERF_SIZE_DWORD Or PERF_TYPE_COUNTER Or PERF_COUNTER_RATE Or PERF_TIMER_TICK Or PERF_DELTA_COUNTER Or PERF_DISPLAY_PER_SEC)

' 64-bit Timer. Divide delta by delta time. Display suffix: "%"

Const PERF_COUNTER_TIMER = (PERF_SIZE_LARGE Or PERF_TYPE_COUNTER Or PERF_COUNTER_RATE Or PERF_TIMER_TICK Or PERF_DELTA_COUNTER Or PERF_DISPLAY_PERCENT)

' Queue Length Space-Time Product. Divide delta by delta time. No Display Suffix.

Const PERF_COUNTER_QUEUELEN_TYPE = (PERF_SIZE_DWORD Or PERF_TYPE_COUNTER Or PERF_COUNTER_QUEUELEN Or PERF_TIMER_TICK Or PERF_DELTA_COUNTER Or PERF_DISPLAY_NO_SUFFIX)

' 64-bit Counter. Divide delta by delta time. Display Suffix: "/sec"

Const PERF_COUNTER_BULK_COUNT = (PERF_SIZE_LARGE Or PERF_TYPE_COUNTER Or PERF_COUNTER_RATE Or PERF_TIMER_TICK Or PERF_DELTA_COUNTER Or PERF_DISPLAY_PER_SEC)

' Indicates the counter is not a counter but rather Unicode text Display as text.

Const PERF_COUNTER_TEXT = (PERF_SIZE_VARIABLE_LEN Or PERF_TYPE_TEXT Or PERF_TEXT_UNICODE Or PERF_DISPLAY_NO_SUFFIX)

' Indicates the data is a counter which should not be

' time averaged on display (such as an error counter on a serial line)

' Display as is. No Display Suffix.

Const PERF_COUNTER_RAWCOUNT = (PERF_SIZE_DWORD Or PERF_TYPE_NUMBER Or PERF_NUMBER_DECIMAL Or PERF_DISPLAY_NO_SUFFIX)

' A count which is either 1 or 0 on each sampling interrupt (% busy)

' Divide delta by delta base. Display Suffix: "%"

Const PERF_SAMPLE_FRACTION = (PERF_SIZE_DWORD Or PERF_TYPE_COUNTER Or PERF_COUNTER_FRACTION Or PERF_DELTA_COUNTER Or PERF_DELTA_BASE Or PERF_DISPLAY_PERCENT)

' A count which is sampled on each sampling interrupt (queue length)

' Divide delta by delta time. No Display Suffix.

Const PERF_SAMPLE_COUNTER = (PERF_SIZE_DWORD Or PERF_TYPE_COUNTER Or PERF_COUNTER_RATE Or PERF_TIMER_TICK Or PERF_DELTA_COUNTER Or PERF_DISPLAY_NO_SUFFIX)

' A label: no data is associated with this counter (it has 0 length)

' Do not display.

Const PERF_COUNTER_NODATA = (PERF_SIZE_ZERO Or PERF_DISPLAY_NOSHOW)

' 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_COUNTER_TIMER_INV = (PERF_SIZE_LARGE Or PERF_TYPE_COUNTER Or PERF_COUNTER_RATE Or PERF_TIMER_TICK Or PERF_DELTA_COUNTER Or PERF_INVERSE_COUNTER Or PERF_DISPLAY_PERCENT)

【分享成果,随喜正能量】放下怒气,化解戾气,多一些善意,多一些和气,生活的喜与福,都是你内心的显化。所有的相遇,最终都会别离,只是告别的方式不同而已。这当中,没有可惜,没有不幸,只因这世界所有的故事,从缘起,从缘灭。。

我2多年的VBA实践经验,全部浓缩在下面的各个教程中:

  • 发表于:
  • 原文链接https://page.om.qq.com/page/Obnk_pNkPMB8MZTAbloxPPzQ0
  • 腾讯「腾讯云开发者社区」是腾讯内容开放平台帐号(企鹅号)传播渠道之一,根据《腾讯内容开放平台服务协议》转载发布内容。
  • 如有侵权,请联系 cloudcommunity@tencent.com 删除。

扫码

添加站长 进交流群

领取专属 10元无门槛券

私享最新 技术干货

扫码加入开发者社群
领券