Outlook VBA-使用Outlook 2010 64位每半小时运行一次代码 [英] Outlook VBA - Run a code every half an hour with outlook 2010 64 bits
问题描述
此问题之前已完成(并已解决),请参见 Outlook VBA-每半小时运行一次代码 几年前,我在几台运行Vista(32位),Windows 7和Windows 8.1(全部64位)的计算机上都正常使用代码.安装了新的Office 2010的新计算机会出现一些问题.
This question is done (and solved) before, see Outlook VBA - Run a code every half an hour I used the code fore several years on with no trouble on several computers running Vista (32 bit), Windows 7 and Windows 8.1 (all 64 bit). A new computer with a new office 2010 installation gives some problems.
Outlook的64位版本似乎与32位版本有所不同. 这些行我出错了
The 64 bit version of outlook seems to react different as the 32 bit version. I get errors with these lines
Declare Function SetTimer Lib "user32" (ByVal hwnd As Long, ByVal nIDEvent As Long, ByVal uElapse As Long, ByVal lpTimerfunc As Long) As Long
Declare Function KillTimer Lib "user32" (ByVal hwnd As Long, ByVal nIDEvent As Long) As Long
可以使用PtrSafe进行纠正,例如:
This can be corrected with PtrSafe like:
Declare Function PtrSafe SetTimer Lib "user32" (ByVal hwnd As Long, ByVal nIDEvent As Long, ByVal uElapse As Long, ByVal lpTimerfunc As Long) As Long
Declare Function PtrSafe KillTimer Lib "user32" (ByVal hwnd As Long, ByVal nIDEvent As Long) As Long
该行中出现另一个错误:
An other error appear in the line:
TimerID = SetTimer(0, 0, nMinutes, AddressOf TriggerTimer)
类型似乎不同.
推荐答案
PtrSafe
并没有更正代码,只是指出可以从64位代码中调用以下声明.
PtrSafe
is not correcting the code, its simply stating that the following declare can be called from 64 bit code.
AddressOf
返回的指针原型为32位的ByVal lpTimerfunc As Long
.即太小,无法容纳64位地址. hwnd
也是如此.
The pointer returned by AddressOf
is prototyped as ByVal lpTimerfunc As Long
which is 32 bits; i.e. too small to accommodate a 64 bit address. The same is true of hwnd
.
使用 LongPtr
输入即可解决此问题.
Use the LongPtr
type to deal with this.
这篇关于Outlook VBA-使用Outlook 2010 64位每半小时运行一次代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!