PtrSafe

来源:互联网 发布:广州大数据 平台 编辑:程序博客网 时间:2024/06/07 16:43

办公室终于换新电脑了,我那08年的老机器终于退役了……大哭

好吧,新机器8G内存,果断上64位系统

运行之前写的vba小程序,嗯?!提示要增加PtrSafe,去查了一圈,原来是这么回事儿啊

https://msdn.microsoft.com/zh-cn/library/gg278832.aspx

PtrSafe <keyword>

Office 2013

Last modified: December 06, 2011

Applies to: Office 2013 | VBA

The PtrSafe keyword is used in this context:

Declare Statement

Note Note

Declare statements with the PtrSafe keyword is the recommended syntax. Declare statements that include PtrSafe work correctly in the VBA7 development environment on both 32-bit and 64-bit platforms only after all data types in the Declarestatement (parameters and return values) that need to store 64-bit quantities are updated to use LongLong for 64-bit integrals or LongPtr for pointers and handles. To ensure backwards compatibility with VBA version 6 and earlier use the following construct:

VBA
#If Vba7 Then Declare PtrSafe Sub... #Else Declare Sub... #EndIf

When running in 64-bit versions of Office Declare statements must include the PtrSafe keyword.

The PtrSafe keyword asserts that a Declare statement is safe to run in 64-bit development environments.

Adding the PtrSafe keyword to a Declare statement only signifies the Declare statement explicitly targets 64-bits, all data types within the statement that need to store 64-bits (including return values and parameters) must still be modified to hold 64-bit quantities using either LongLong for 64-bit integrals or LongPtr for pointers and handles.


PtrSafe <keyword>

Office 2013

上次修改时间: 2011年12月6日

适用范围: Office 2013 | VBA

将"PtrSafe"关键字用于以下上下文:

Declare 语句

注释 注释

含"PtrSafe"关键字的 Declare 语句是推荐的语法。包含"PtrSafe"的 Declare 语句在 32 位和 64 位的平台上的 VBA7 开发环境中正常工作,只是要在需要存储 64 位数量的"Declare"语句(参数和返回值)中的所有数据类型被更新以将 LongLong 用于 64 位整数,或将LongPtr 用于指针和句柄。为了确保 VBA 版本 6 和更早版本的向后兼容性,请使用以下构造:

VBA
#If Vba7 Then Declare PtrSafe Sub... #Else Declare Sub... #EndIf

当在 Office 的 64 位版本中运行时,"Declare"语句必须包括"PtrSafe"关键字。

"PtrSafe"关键字断定"Declare"语句在 64 位的开发环境中运行是安全的。

将"PtrSafe"关键字添加到"Declare"语句只表明了"Declare"明确地以 64 位为目标,必须修改该语句中的所有需要存储 64 位的数据类型(包括返回值和参数)以通过将 LongLong 用于 64 位整数或将 LongPtr 用于指针和句柄来保留 64 位数量。



0 0