优秀的编程知识分享平台

网站首页 > 技术文章 正文

64位Office API声明语句第107讲

nanyue 2024-07-29 01:12:14 技术文章 7 ℃

【分享成果,随喜正能量】求福当求永久福,增寿当增无量寿;求福当求智慧福,增寿当增慈悲寿。。

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

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

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

Const SERVICE_QUERY_STATUS = &H4

Const SERVICE_ENUMERATE_DEPENDENTS = &H8

Const SERVICE_START = &H10

Const SERVICE_STOP = &H20

Const SERVICE_PAUSE_CONTINUE = &H40

Const SERVICE_INTERROGATE = &H80

Const SERVICE_USER_DEFINED_CONTROL = &H100

Const SERVICE_ALL_ACCESS = (STANDARD_RIGHTS_REQUIRED Or SERVICE_QUERY_CONFIG Or SERVICE_CHANGE_CONFIG Or SERVICE_QUERY_STATUS Or SERVICE_ENUMERATE_DEPENDENTS Or SERVICE_START Or SERVICE_STOP Or SERVICE_PAUSE_CONTINUE Or SERVICE_INTERROGATE Or SERVICE_USER_DEFINED_CONTROL)

Type SERVICE_STATUS

dwServiceType As Long

dwCurrentState As Long

dwControlsAccepted As Long

dwWin32ExitCode As Long

dwServiceSpecificExitCode As Long

dwCheckPoint As Long

dwWaitHint As Long

End Type

Type ENUM_SERVICE_STATUS

lpServiceName As String

lpDisplayName As String

ServiceStatus As SERVICE_STATUS

End Type

Type QUERY_SERVICE_LOCK_STATUS

fIsLocked As Long

lpLockOwner As String

dwLockDuration As Long

End Type

Type QUERY_SERVICE_CONFIG

dwServiceType As Long

dwStartType As Long

dwErrorControl As Long

lpBinaryPathName As String

lpLoadOrderGroup As String

dwTagId As Long

lpDependencies As String

lpServiceStartName As String

lpDisplayName As String

End Type

Type SERVICE_TABLE_ENTRY

lpServiceName As String

lpServiceProc As LongPtr

End Type

' ++ BUILD Version: 0010 ' Increment this if a change has global effects

' Copyright (c) 1995 Microsoft Corporation

' Module Name:

' winsvc.h

' Abstract:

' Header file for the Service Control Manager

' Environment:

' User Mode - Win32

' --*/

'

' Constants

' Character to designate that a name is a group

'

Const SC_GROUP_IDENTIFIER = "+"

' Prototype for the Service Control Handler Function

' /////////////////////////////////////////////////////////////////////////

' API Function Prototypes

' /////////////////////////////////////////////////////////////////////////

Declare PtrSafe Function ChangeServiceConfig Lib "advapi32.dll" Alias "ChangeServiceConfigA" (ByVal hService As LongPtr, ByVal dwServiceType As Long, ByVal dwStartType As Long, ByVal dwErrorControl As Long, ByVal lpBinaryPathName As String, ByVal lpLoadOrderGroup As String, lpdwTagId As Long, ByVal lpDependencies As String, ByVal lpServiceStartName As String, ByVal lpPassword As String, ByVal lpDisplayName As String) As Long

Declare PtrSafe Function CloseServiceHandle Lib "advapi32.dll" Alias "CloseServiceHandle" (ByVal hSCObject As LongPtr) As Long

Declare PtrSafe Function ControlService Lib "advapi32.dll" Alias "ControlService" (ByVal hService As LongPtr, ByVal dwControl As Long, lpServiceStatus As SERVICE_STATUS) As Long

Declare PtrSafe Function CreateService Lib "advapi32.dll" Alias "CreateServiceA" (ByVal hSCManager As LongPtr, ByVal lpServiceName As String, ByVal lpDisplayName As String, ByVal dwDesiredAccess As Long, ByVal dwServiceType As Long, ByVal dwStartType As Long, ByVal dwErrorControl As Long, ByVal lpBinaryPathName As String, ByVal lpLoadOrderGroup As String, lpdwTagId As Long, ByVal lpDependencies As String, ByVal lp As String, ByVal lpPassword As String) As LongPtr

Declare PtrSafe Function DeleteService Lib "advapi32.dll" Alias "DeleteService" (ByVal hService As LongPtr) As Long

Declare PtrSafe Function EnumDependentServices Lib "advapi32.dll" Alias "EnumDependentServicesA" (ByVal hService As LongPtr, ByVal dwServiceState As Long, lpServices As ENUM_SERVICE_STATUS, ByVal cbBufSize As Long, pcbBytesNeeded As Long, lpServicesReturned As Long) As Long

Declare PtrSafe Function EnumServicesStatus Lib "advapi32.dll" Alias "EnumServicesStatusA" (ByVal hSCManager As LongPtr, ByVal dwServiceType As Long, ByVal dwServiceState As Long, lpServices As ENUM_SERVICE_STATUS, ByVal cbBufSize As Long, pcbBytesNeeded As Long, lpServicesReturned As Long, lpResumeHandle As Long) As Long

Declare PtrSafe Function GetServiceKeyName Lib "advapi32.dll" Alias "GetServiceKeyNameA" (ByVal hSCManager As LongPtr, ByVal lpDisplayName As String, ByVal lpServiceName As String, lpcchBuffer As Long) As Long

Declare PtrSafe Function GetServiceDisplayName Lib "advapi32.dll" Alias "GetServiceDisplayNameA" (ByVal hSCManager As LongPtr, ByVal lpServiceName As String, ByVal lpDisplayName As String, lpcchBuffer As Long) As Long

Declare PtrSafe Function LockServiceDatabase Lib "advapi32.dll" Alias "LockServiceDatabase" (ByVal hSCManager As LongPtr) As LongPtr

Declare PtrSafe Function NotifyBootConfigStatus Lib "advapi32.dll" Alias "NotifyBootConfigStatus" (ByVal BootAcceptable As Long) As Long

Declare PtrSafe Function OpenSCManager Lib "advapi32.dll" Alias "OpenSCManagerA" (ByVal lpMachineName As String, ByVal lpDatabaseName As String, ByVal dwDesiredAccess As Long) As LongPtr

Declare PtrSafe Function OpenService Lib "advapi32.dll" Alias "OpenServiceA" (ByVal hSCManager As LongPtr, ByVal lpServiceName As String, ByVal dwDesiredAccess As Long) As LongPtr

Declare PtrSafe Function QueryServiceConfig Lib "advapi32.dll" Alias "QueryServiceConfigA" (ByVal hService As LongPtr, lpServiceConfig As QUERY_SERVICE_CONFIG, ByVal cbBufSize As Long, pcbBytesNeeded As Long) As Long

Declare PtrSafe Function QueryServiceLockStatus Lib "advapi32.dll" Alias "QueryServiceLockStatusA" (ByVal hSCManager As LongPtr, lpLockStatus As QUERY_SERVICE_LOCK_STATUS, ByVal cbBufSize As Long, pcbBytesNeeded As Long) As Long

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

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

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

【分享成果,随喜正能量】 人更重要的是,有能力自我恢复,自我复活,自我解救,自我救赎;永远不要指望任何人。。

Tags:

最近发表
标签列表