VBA 64位API声明语句第012讲

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

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

【分享成果,随喜正能量】222 苦非苦,乐非乐,只是一时的执念而已。执于一念,将受困于一念;一念放下,会自在于心间。物随心转,境由心造,烦恼皆由心生。有些人,有些事,是可遇不可求的,强求只有痛苦。既然这样,就放宽心态,顺其自然。无论何时何地,都要拥有一颗安闲自在的心,保持豁达的心态。

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

Declare PtrSafe Function ContinueDebugEvent Lib "kernel32" Alias "ContinueDebugEvent" (ByVal dwProcessId As Long, ByVal dwThreadId As Long, ByVal dwContinueStatus As Long) As Long

Declare PtrSafe Function DebugActiveProcess Lib "kernel32" Alias "DebugActiveProcess" (ByVal dwProcessId As Long) As Long

Type CRITICAL_SECTION

DebugInfo As LongPtr

LockCount As Long

RecursionCount As Long

OwningThread As LongPtr

LockSemaphore As LongPtr

SpinCount As LongPtr

End Type

Declare PtrSafe Sub InitializeCriticalSection Lib "kernel32" Alias "InitializeCriticalSection" (lpCriticalSection As CRITICAL_SECTION)

Declare PtrSafe Sub EnterCriticalSection Lib "kernel32" Alias "EnterCriticalSection" (lpCriticalSection As CRITICAL_SECTION)

Declare PtrSafe Sub LeaveCriticalSection Lib "kernel32" Alias "LeaveCriticalSection" (lpCriticalSection As CRITICAL_SECTION)

Declare PtrSafe Sub DeleteCriticalSection Lib "kernel32" Alias "DeleteCriticalSection" (lpCriticalSection As CRITICAL_SECTION)

Declare PtrSafe Function SetEvent Lib "kernel32" Alias "SetEvent" (ByVal hEvent As LongPtr) As Long

Declare PtrSafe Function ResetEvent Lib "kernel32" Alias "ResetEvent" (ByVal hEvent As LongPtr) As Long

Declare PtrSafe Function PulseEvent Lib "kernel32" Alias "PulseEvent" (ByVal hEvent As LongPtr) As Long

Declare PtrSafe Function ReleaseSemaphore Lib "kernel32" Alias "ReleaseSemaphore" (ByVal hSemaphore As LongPtr, ByVal lReleaseCount As Long, lpPreviousCount As Long) As Long

Declare PtrSafe Function ReleaseMutex Lib "kernel32" Alias "ReleaseMutex" (ByVal hMutex As LongPtr) As Long

Declare PtrSafe Function WaitForSingleObject Lib "kernel32" Alias "WaitForSingleObject" (ByVal hHandle As LongPtr, ByVal dwMilliseconds As Long) As Long

Declare PtrSafe Function WaitForMultipleObjects Lib "kernel32" Alias "WaitForMultipleObjects" (ByVal nCount As Long, lpHandles As LongPtr, ByVal bWaitAll As Long, ByVal dwMilliseconds As Long) As Long

Declare PtrSafe Sub Sleep Lib "kernel32" Alias "Sleep" (ByVal dwMilliseconds As Long)

Declare PtrSafe Sub OutputDebugString Lib "kernel32" Alias "OutputDebugStringA" (ByVal lpOutputString As String)

Declare PtrSafe Function GetVersion Lib "kernel32" Alias "GetVersion" () As Long

Declare PtrSafe Function OpenFile Lib "kernel32" Alias "OpenFile" (ByVal lpFileName As String, lpReOpenBuff As OFSTRUCT, ByVal wStyle As Long) As Long

' GetTempFileName() Flags

'

Const TF_FORCEDRIVE = &H80

Declare PtrSafe Function GetTempFileName Lib "kernel32" Alias "GetTempFileNameA" (ByVal lpszPath As String, ByVal lpPrefixString As String, ByVal wUnique As Long, ByVal lpTempFileName As String) As Long

Declare PtrSafe Function SetHandleCount Lib "kernel32" Alias "SetHandleCount" (ByVal wNumber As Long) As Long

Declare PtrSafe Function GetLogicalDrives Lib "kernel32" Alias "GetLogicalDrives" () As Long

Declare PtrSafe Function LockFile Lib "kernel32" Alias "LockFile" (ByVal hFile As LongPtr, ByVal dwFileOffsetLow As Long, ByVal dwFileOffsetHigh As Long, ByVal nNumberOfBytesToLockLow As Long, ByVal nNumberOfBytesToLockHigh As Long) As Long

Declare PtrSafe Function UnlockFile Lib "kernel32" Alias "UnlockFile" (ByVal hFile As LongPtr, ByVal dwFileOffsetLow As Long, ByVal dwFileOffsetHigh As Long, ByVal nNumberOfBytesToUnlockLow As Long, ByVal nNumberOfBytesToUnlockHigh As Long) As Long

Declare PtrSafe Function LockFileEx Lib "kernel32" Alias "LockFileEx" (ByVal hFile As LongPtr, ByVal dwFlags As Long, ByVal dwReserved As Long, ByVal nNumberOfBytesToLockLow As Long, ByVal nNumberOfBytesToLockHigh As Long, lpOverlapped As OVERLAPPED) As Long

Const LOCKFILE_FAIL_IMMEDIATELY = &H1

Const LOCKFILE_EXCLUSIVE_LOCK = &H2

Declare PtrSafe Function UnlockFileEx Lib "kernel32" Alias "UnlockFileEx" (ByVal hFile As LongPtr, ByVal dwReserved As Long, ByVal nNumberOfBytesToUnlockLow As Long, ByVal nNumberOfBytesToUnlockHigh As Long, lpOverlapped As OVERLAPPED) As Long

Type BY_HANDLE_FILE_INFORMATION

dwFileAttributes As Long

ftCreationTime As FILETIME

ftLastAccessTime As FILETIME

ftLastWriteTime As FILETIME

dwVolumeSerialNumber As Long

nFileSizeHigh As Long

nFileSizeLow As Long

nNumberOfLinks As Long

nFileIndexHigh As Long

nFileIndexLow As Long

End Type

Declare PtrSafe Function GetFileInformationByHandle Lib "kernel32" Alias "GetFileInformationByHandle" (ByVal hFile As LongPtr, lpFileInformation As BY_HANDLE_FILE_INFORMATION) As Long

Declare PtrSafe Function GetFileType Lib "kernel32" Alias "GetFileType" (ByVal hFile As LongPtr) As Long

Declare PtrSafe Function GetFileSize Lib "kernel32" Alias "GetFileSize" (ByVal hFile As LongPtr, lpFileSizeHigh As Long) As Long

Declare PtrSafe Function GetStdHandle Lib "kernel32" Alias "GetStdHandle" (ByVal nStdHandle As Long) As LongPtr

Declare PtrSafe Function SetStdHandle Lib "kernel32" Alias "SetStdHandle" (ByVal nStdHandle As Long, ByVal nHandle As LongPtr) As Long

Declare PtrSafe Function WriteFile Lib "kernel32" Alias "WriteFile" (ByVal hFile As LongPtr, lpBuffer As Any, ByVal nNumberOfBytesToWrite As Long, lpNumberOfBytesWritten As Long, lpOverlapped As OVERLAPPED) As Long

Declare PtrSafe Function ReadFile Lib "kernel32" Alias "ReadFile" (ByVal hFile As LongPtr, lpBuffer As Any, ByVal nNumberOfBytesToRead As Long, lpNumberOfBytesRead As Long, lpOverlapped As OVERLAPPED) As Long

Declare PtrSafe Function FlushFileBuffers Lib "kernel32" Alias "FlushFileBuffers" (ByVal hFile As LongPtr) As Long

Declare PtrSafe Function DeviceIoControl Lib "kernel32" Alias "DeviceIoControl" (ByVal hDevice As LongPtr, ByVal dwIoControlCode As Long, lpInBuffer As Any, ByVal nInBufferSize As Long, lpOutBuffer As Any, ByVal nOutBufferSize As Long, lpBytesReturned As Long, lpOverlapped As OVERLAPPED) As Long

Declare PtrSafe Function SetEndOfFile Lib "kernel32" Alias "SetEndOfFile" (ByVal hFile As LongPtr) As Long

Declare PtrSafe Function SetFilePointer Lib "kernel32" Alias "SetFilePointer" (ByVal hFile As LongPtr, ByVal lDistanceToMove As Long, lpDistanceToMoveHigh As Long, ByVal dwMoveMethod As Long) As Long

Declare PtrSafe Function FindClose Lib "kernel32" Alias "FindClose" (ByVal hFindFile As LongPtr) As Long

Declare PtrSafe Function GetFileTime Lib "kernel32" Alias "GetFileTime" (ByVal hFile As LongPtr, lpCreationTime As FILETIME, lpLastAccessTime As FILETIME, lpLastWriteTime As FILETIME) As Long

Declare PtrSafe Function SetFileTime Lib "kernel32" Alias "SetFileTime" (ByVal hFile As LongPtr, lpCreationTime As FILETIME, lpLastAccessTime As FILETIME, lpLastWriteTime As FILETIME) As Long

Declare PtrSafe Function CloseHandle Lib "kernel32" Alias "CloseHandle" (ByVal hObject As LongPtr) As Long

Declare PtrSafe Function DuplicateHandle Lib "kernel32" Alias "DuplicateHandle" (ByVal hSourceProcessHandle As LongPtr, ByVal hSourceHandle As LongPtr, ByVal hTargetProcessHandle As LongPtr, lpTargetHandle As LongPtr, ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwOptions As Long) As Long

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



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值