【问题标题】:MsgWaitForMultipleObjects returns error for Office 2013 64-bit versionMsgWaitForMultipleObjects 返回 Office 2013 64 位版本的错误
【发布时间】:2013-01-23 07:48:59
【问题描述】:

我的公司有一个可以在 Office 2007 和 2010 上正常运行的 Office 插件。现在微软有了新的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。

谢谢。

【问题讨论】:

    标签: ms-office add-in office-addins office-2013


    【解决方案1】:

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

    【讨论】:

      猜你喜欢
      • 2011-05-14
      • 2014-12-18
      • 2017-09-15
      • 2016-01-24
      • 2018-08-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-03-11
      相关资源
      最近更新 更多