我的公司有一个Office插件,可以在Office 2007和2010上正常运行。现在Microsoft有一个新的Office 2013,我们需要在Office 2013(32位和64位)中测试加载项。
大多数函数都运行正常,但不知何故有一个函数使用MsgWaitForMultipleObjects()在Office 2013 64位版本中无法正常工作,它在32位Office 2013上运行正常。下面是我的代码,它属于一个功能:
Dim lReturn As Integer
Do While True
'Wait on event
lReturn = MsgWaitForMultipleObjects(1, handle, 0, timeout, QS_ALLEVENTS)
Select Case lReturn
Case -1
'Call failed
Err.Raise(vbObjectError, "WaitWithEvents", "MsgWaitForMultipleObjects Failed")
Case STATUS_TIMEOUT
'Timed out
WaitWithEvents = STATUS_TIMEOUT
Exit Function
Case 1
'Event needs to be processed
Application.DoEvents()
Case Else
'Event has been signaled
WaitWithEvents = 0
Exit Function
End Select
Loop
大多数情况下,MsgWaitForMultipleObjects()将返回-1,Office应用程序将崩溃/挂起。我是MsgWaitForMultipleObjects()的新手,并试图在这里和那里更改代码,但仍然无法解决问题。
MsgWaitForMultipleObjects()在64位版本的Office 2013中运行良好吗?或者需要针对64位Office进行一些修改?或者我需要以不同方式注册DLL?加载项项目设置为任何cpu。
感谢。
答案 0 :(得分:0)
我找到了解决方案,问题出在MsgWaitForMultipleObjects()的声明中。 以前我这样说过:
Private Declare Function MsgWaitForMultipleObjects Lib "user32" (ByVal nCount As Integer, ByRef pHandles As Integer, ByVal fWaitAll As Integer, ByVal dwMilliseconds As Integer, ByVal dwWakeMask As Integer) As Integer
解决方案是:
Private Declare Function MsgWaitForMultipleObjects Lib "user32" (ByVal nCount As Integer, ByRef pHandles As IntPtr, ByVal fWaitAll As Boolean, ByVal dwMilliseconds As UInteger, ByVal dwWakeMask As Integer) As Integer