VBA 64位API声明语句第014讲

VBA 64位API声明语句第014讲

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

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

【分享成果,随喜正能量】282升米恩,斗米仇。不要成为一个没有原则的滥好人,否则你帮助过的人不会感谢你,你没帮助到的人会怨恨你。我想起了有一个笑话,某个乞丐在街上祈祷,A路过后天天给了他10块钱,B看乞丐好欺负,天天打他一顿。某天A突然忘带零钱了,乞丐问他说你今天怎么不给我钱!某天B忘记打了乞丐,乞丐却感激涕零觉得B内心其实是一个好人。虽然是个笑话,不过对我们理解道理有所帮助。

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

Declare PtrSafe Function GetThreadContext Lib "kernel32" Alias "GetThreadContext" (ByVal hThread As LongPtr, lpContext As CONTEXT) As Long

Declare PtrSafe Function SetThreadContext Lib "kernel32" Alias "SetThreadContext" (ByVal hThread As LongPtr, lpContext As CONTEXT) As Long

Declare PtrSafe Function SuspendThread Lib "kernel32" Alias "SuspendThread" (ByVal hThread As LongPtr) As Long

Declare PtrSafe Function ResumeThread Lib "kernel32" Alias "ResumeThread" (ByVal hThread As LongPtr) As Long

Declare PtrSafe Function FindResource Lib "kernel32" Alias "FindResourceA" (ByVal hInstance As LongPtr, ByVal lpName As String, ByVal lpType As String) As LongPtr

Declare PtrSafe Function FindResourceEx Lib "kernel32" Alias "FindResourceExA" (ByVal hModule As LongPtr, ByVal lpType As String, ByVal lpName As String, ByVal wLanguage As Long) As LongPtr

Declare PtrSafe Function BeginUpdateResource Lib "kernel32" Alias "BeginUpdateResourceA" (ByVal pFileName As String, ByVal bDeleteExistingResources As Long) As LongPtr

Declare PtrSafe Function UpdateResource Lib "kernel32" Alias "UpdateResourceA" (ByVal hUpdate As LongPtr, ByVal lpType As String, ByVal lpName As String, ByVal wLanguage As Long, lpData As Any, ByVal cbData As Long) As Long

Declare PtrSafe Function EndUpdateResource Lib "kernel32" Alias "EndUpdateResourceA" (ByVal hUpdate As LongPtr, ByVal fDiscard As Long) As Long

Declare PtrSafe Function LoadResource Lib "kernel32" Alias "LoadResource" (ByVal hInstance As LongPtr, ByVal hResInfo As LongPtr) As LongPtr

Declare PtrSafe Function LockResource Lib "kernel32" Alias "LockResource" (ByVal hResData As LongPtr) As LongPtr

Declare PtrSafe Function SizeofResource Lib "kernel32" Alias "SizeofResource" (ByVal hInstance As LongPtr, ByVal hResInfo As LongPtr) As Long

' Predefined Resource Types

Const RT_CURSOR = 1&

Const RT_BITMAP = 2&

Const RT_ICON = 3&

Const RT_MENU = 4&

Const RT_DIALOG = 5&

Const RT_STRING = 6&

Const RT_FONTDIR = 7&

Const RT_FONT = 8&

Const RT_ACCELERATOR = 9&

Const RT_RCDATA = 10&

Declare PtrSafe Function InitAtomTable Lib "kernel32" Alias "InitAtomTable" (ByVal nSize As Long) As Long

Declare PtrSafe Function GlobalAddAtom Lib "kernel32" Alias "GlobalAddAtomA" (ByVal lpString As String) As Integer

Declare PtrSafe Function GlobalDeleteAtom Lib "kernel32" Alias "GlobalDeleteAtom" (ByVal nAtom As Integer) As Integer

Declare PtrSafe Function GlobalFindAtom Lib "kernel32" Alias "GlobalFindAtomA" (ByVal lpString As String) As Integer

Declare PtrSafe Function GlobalGetAtomName Lib "kernel32" Alias "GlobalGetAtomNameA" (ByVal nAtom As Integer, ByVal lpBuffer As String, ByVal nSize As Long) As Long

' User Profile Routines

' NOTE: The lpKeyName argument for GetProfileString, WriteProfileString,

' GetPrivateProfileString, and WritePrivateProfileString can be either

' a string or NULL. This is why the argument is defined as "As Any".

' For example, to pass a string specify ByVal "wallpaper"

' To pass NULL specify ByVal 0&

' You can also pass NULL for the lpString argument for WriteProfileString

' and WritePrivateProfileString

Declare PtrSafe Function GetProfileInt Lib "kernel32" Alias "GetProfileIntA" (ByVal lpAppName As String, ByVal lpKeyName As String, ByVal nDefault As Long) As Long

Declare PtrSafe Function GetProfileString Lib "kernel32" Alias "GetProfileStringA" (ByVal lpAppName As String, ByVal lpKeyName As String, ByVal lpDefault As String, ByVal lpReturnedString As String, ByVal nSize As Long) As Long

Declare PtrSafe Function WriteProfileString Lib "kernel32" Alias "WriteProfileStringA" (ByVal lpszSection As String, ByVal lpszKeyName As String, ByVal lpszString As String) As Long

Declare PtrSafe Function GetProfileSection Lib "kernel32" Alias "GetProfileSectionA" (ByVal lpAppName As String, ByVal lpReturnedString As String, ByVal nSize As Long) As Long

Declare PtrSafe Function WriteProfileSection Lib "kernel32" Alias "WriteProfileSectionA" (ByVal lpAppName As String, ByVal lpString As String) As Long

Declare PtrSafe Function GetPrivateProfileInt Lib "kernel32" Alias "GetPrivateProfileIntA" (ByVal lpApplicationName As String, ByVal lpKeyName As String, ByVal nDefault As Long, ByVal lpFileName As String) As Long

Declare PtrSafe Function GetPrivateProfileString Lib "kernel32" Alias "GetPrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As Any, ByVal lpDefault As String, ByVal lpReturnedString As String, ByVal nSize As Long, ByVal lpFileName As String) As Long

Declare PtrSafe Function WritePrivateProfileString Lib "kernel32" Alias "WritePrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As Any, ByVal lpString As Any, ByVal lpFileName As String) As Long

Declare PtrSafe Function GetPrivateProfileSection Lib "kernel32" Alias "GetPrivateProfileSectionA" (ByVal lpAppName As String, ByVal lpReturnedString As String, ByVal nSize As Long, ByVal lpFileName As String) As Long

Declare PtrSafe Function WritePrivateProfileSection Lib "kernel32" Alias "WritePrivateProfileSectionA" (ByVal lpAppName As String, ByVal lpString As String, ByVal lpFileName As String) As Long

Declare PtrSafe Function Get『Windows』Directory Lib "kernel32" Alias "Get『Windows』DirectoryA" (ByVal lpBuffer As String, ByVal nSize As Long) As Long

Declare PtrSafe Function GetSystemDirectory Lib "kernel32" Alias "GetSystemDirectoryA" (ByVal lpBuffer As String, ByVal nSize As Long) As Long

Declare PtrSafe Function GetTempPath Lib "kernel32" Alias "GetTempPathA" (ByVal nBufferLength As Long, ByVal lpBuffer As String) As Long

Declare PtrSafe Function SetCurrentDirectory Lib "kernel32" Alias "SetCurrentDirectoryA" (ByVal lpPathName As String) As Long

Declare PtrSafe Function GetCurrentDirectory Lib "kernel32" Alias "GetCurrentDirectory" (ByVal nBufferLength As Long, ByVal lpBuffer As String) As Long

Declare PtrSafe Function GetDiskFreeSpace Lib "kernel32" Alias "GetDiskFreeSpaceA" (ByVal lpRootPathName As String, lpSectorsPerCluster As Long, lpBytesPerSector As Long, lpNumberOfFreeClusters As Long, lpTotalNumberOfClusters As Long) As Long

Declare PtrSafe Function CreateDirectory Lib "kernel32" Alias "CreateDirectoryA" (ByVal lpPathName As String, lpSecurityAttributes As SECURITY_ATTRIBUTES) As Long

Declare PtrSafe Function CreateDirectoryEx Lib "kernel32" Alias "CreateDirectoryExA" (ByVal lpTemplateDirectory As String, ByVal lpNewDirectory As String, lpSecurityAttributes As SECURITY_ATTRIBUTES) As Long

Declare PtrSafe Function RemoveDirectory Lib "kernel32" Alias "RemoveDirectoryA" (ByVal lpPathName As String) As Long

Declare PtrSafe Function GetFullPathName Lib "kernel32" Alias "GetFullPathNameA" (ByVal lpFileName As String, ByVal nBufferLength As Long, ByVal lpBuffer As String, ByVal lpFilePart As String) As Long

Const DDD_RAW_TARGET_PATH = &H1

Const DDD_REMOVE_DEFINITION = &H2

Const DDD_EXACT_MATCH_ON_REMOVE = &H4

Declare PtrSafe Function DefineDosDevice Lib "kernel32" Alias "DefineDosDeviceA" (ByVal dwFlags As Long, ByVal lpDeviceName As String, ByVal lpTargetPath As String) As Long

Declare PtrSafe Function QueryDosDevice Lib "kernel32" Alias "QueryDosDeviceA" (ByVal lpDeviceName As String, ByVal lpTargetPath As String, ByVal ucchMax As Long) As Long

Declare PtrSafe Function CreateFile Lib "kernel32" Alias "CreateFileA" (ByVal lpFileName As String, ByVal dwDesiredAccess As Long, ByVal dwShareMode As Long, lpSecurityAttributes As SECURITY_ATTRIBUTES, ByVal dwCreationDisposition As Long, ByVal dwFlagsAndAttributes As Long, ByVal hTemplateFile As LongPtr) As LongPtr

Declare PtrSafe Function SetFileAttributes Lib "kernel32" Alias "SetFileAttributesA" (ByVal lpFileName As String, ByVal dwFileAttributes As Long) As Long

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

特别声明:[VBA 64位API声明语句第014讲] 该文观点仅代表作者本人,今日霍州系信息发布平台,霍州网仅提供信息存储空间服务。

猜你喜欢

天然紫水晶中的秘密花园:负晶双尖随形吊坠的魅力(天然紫水晶的鉴别方法)

天然紫水晶负晶双尖随形吊坠是水晶界的一颗独特『明星』️,蕴含了自然雕琢的独特之美。负晶是如何形成的?随形吊坠背后又隐藏着怎样的神秘故事?本文将为你深度解读这一迷人宝石的奥秘及其美学价值。

天然紫水晶中的秘密花园:负晶双尖随形吊坠的魅力(天然紫水晶的鉴别方法)

钱再多有什么用?从主持人到"精神病",48岁的李维嘉现状令人唏嘘(钱再多够用就行)

也有一种说法是,李维嘉在和『李湘』搭档主持节目时,7年恋情被曝光,并且表示会很快的结婚,只不过后来就没有什么水花了。感情之路并不顺遂的李维嘉,事业上也遇到了坎坷,主持多年的综艺被停播,甚至还卷入了纠纷之中。 …

钱再多有什么用?从主持人到"精神病",48岁的李维嘉现状令人唏嘘(钱再多够用就行)

DNF账号金库金币上限到底能存多少?真相揭秘!(dnf账号金库金币怎么用)

DNF账号金库金币上限是玩家最关心的游戏经济问题之一。本文深度解析金币存储机制、实际容量限制及背后设计逻辑,帮你彻底搞懂“金库到底能装多少金币”,避免因误解导致资源浪费或操作失误。

DNF账号金库金币上限到底能存多少?真相揭秘!(dnf账号金库金币怎么用)

千万别买!成本0.5元,售价上千元,央视曝光了(成本太贵了)

商户称,这些批发价在60元上下的银戒托莫桑石戒指💍,在不少『直播间』被包装成“培育钻石”售卖。 在浙江杭州黄金珠宝饰品质量检验中心,工作人员将记者在『直播间』内购买的两枚单价在150元的号称是培育钻石的戒指💍进行了检测…

千万别买!成本0.5元,售价上千元,央视曝光了(成本太贵了)

2025年新款:电动鼻毛修剪器引领男士时尚新潮流(2025年新款电子狗)

为什么2025年的充电式电动鼻毛修剪器成为男性♂️个人护理领域的新宠?这款设备不仅提升了男士日常护理的便捷性,还以其独特的设计和卓越性能满足了不同人群的需求。本文深入探讨了其创新功能、应用场景及选购指南。

2025年新款:电动鼻毛修剪器引领男士时尚新潮流(2025年新款电子狗)