Ms office MsgWaitForMultipleObjects返回Office 2013 64位版本的错误

Ms office MsgWaitForMultipleObjects返回Office 2013 64位版本的错误,ms-office,add-in,office-addins,office-2013,Ms Office,Add In,Office Addins,Office 2013,我的公司有一个Office插件,可以在Office2007和2010上正常工作。现在Microsoft有了新的Office 2013,我们需要在Office 2013中测试外接程序(32位和64位) 大多数函数都可以正常工作,但有一个使用MsgWaitForMultipleObjects()的函数在Office 2013 64位版本中工作不正常,它在32位Office 2013上工作正常。下面是我的代码,它在一个函数中: Dim lReturn As Integer Do While Tr

我的公司有一个Office插件,可以在Office2007和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


谢谢。

我找到了解决方案,问题在于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