xsk199529 发表于 2018-6-26 20:14:54

AutoCAD2014及以上版本配套采用VBA7.1,关于API的声明方法

AutoCAD2014及以上版本配套采用VBA7.1,与以前的VBA6.0版本有一些区别,关于多个CAD版本下的API声明方法如下:

Option Explicit

Option Compare Text
'---------------------------------------------------------------
'- 注册表 API 声明...
'---------------------------------------------------------------
#If VBA7 Then
'VBA7打开注册表中指定的键
Private Declare PtrSafe Function RegOpenKey Lib "advapi32.dll" Alias "RegOpenKeyA" _
    (ByVal hKey As Long, ByVal lpSubKey As String, phkResult As Long) As Long
' 修注册表中某个键的值
Private Declare PtrSafe Function RegSetValue Lib "advapi32.dll" Alias "RegSetValueA" _
    (ByVal hKey As Long, ByVal lpSubKey As String, ByVal dwType As Long, _
    ByVal lpData As String, ByVal cbData As Long) As Long
' 关闭打开的键
Private Declare PtrSafe Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) As Long
#Else
' VBA6打开注册表中指定的键
Private Declare Function RegOpenKey Lib "advapi32.dll" Alias "RegOpenKeyA" _
    (ByVal hKey As Long, ByVal lpSubKey As String, phkResult As Long) As Long
' 修注册表中某个键的值
Private Declare Function RegSetValue Lib "advapi32.dll" Alias "RegSetValueA" _
    (ByVal hKey As Long, ByVal lpSubKey As String, ByVal dwType As Long, _
    ByVal lpData As String, ByVal cbData As Long) As Long
' 关闭打开的键
Private Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) As Long
#End If

Public WithEvents App As AcadApplication


去啊在 发表于 2018-7-23 05:04:26

mapple666 发表于 2018-8-8 13:44:53

的顶顶顶顶顶多多多多多多多多多

无尘235 发表于 2019-4-23 12:43:25

页: [1]
查看完整版本: AutoCAD2014及以上版本配套采用VBA7.1,关于API的声明方法