我的公司有一个Office插件,可以在Office 2007和2010上运行,没有问题。现在Microsoft有了新的Office 2013,我们需要在Office 2013 (32位和64位)中测试该加载项。
大多数函数都工作得很好,但有一个函数使用MsgWaitForMultipleObjects()在Office2013 64位版本中不能正常工作,它在32位Office2013上工作得很好。下面是我的代码,它在一个函数中:
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大多数时候会返回-1 \f25 MsgWaitForMultipleObjects() -1\f6,-1\f25 Office -1\f6应用程序会崩溃/挂起。我是MsgWaitForMultipleObjects()的新手,我尝试过在这里和那里更改代码,但仍然不能解决问题。
MsgWaitForMultipleObjects()在64位版本的Office2013中是否正常工作?或者需要专门针对64位Office进行一些修改?或者我需要以不同的方式注册DLL?外接程序项目设置为任何cpu。
谢谢。
发布于 2013-02-04 10:59:23
我找到了解决方案,问题出在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 Integerhttps://stackoverflow.com/questions/14474740
复制相似问题