睡眠库"kernel32"给出64位系统错误 [英] Sleep Lib "kernel32" gives 64-bit systems error
问题描述
我正在尝试运行所有功能后关闭访问权限(Application.Quit
).
I'm trying to close access (Application.Quit
) after running all functions.
但是当我Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
时,出现以下错误:
but when I Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
, It's giving me the following error:
该项目中的代码必须进行更新才能在64位系统上使用.
The code in this project must be updated for use on 64 bit systems.
在完全关闭访问权限之前,是否可以替换此代码来运行所有功能?
Is there any replacement of this code to do run all functions before completely closing access?
推荐答案
dwMilliseconds
参数是DWORD,因此从技术上讲,它将在32位计算机上为32位,在64位计算机上为64位.因此,它需要PtrSafe
表示法(尽管从技术上讲dwMilliseconds
会正确地编组,因为它是ByVal
...而且无论如何都要等待那么长时间)将声明更改为:
The dwMilliseconds
parameter is a DWORD, so it will technically be 32bit on a 32bit machine and 64bit on a 64bit machine. Because of this, it requires PtrSafe
notation (although technically dwMilliseconds
will marshal correctly because it's ByVal
... and who wants to wait that long anyway) Change the declaration to this:
#If VBA7 Then
Declare PtrSafe Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As LongPtr)
#Else
Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
#End If
这篇关于睡眠库"kernel32"给出64位系统错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!