2013-01-23 60 views
0

我的公司有一個可以在Office 2007和2010上正常工作的Office加載項。現在Microsoft有了新的Office 2013,我們需要測試Office 2013(32位和64位)中的加載項。MsgWaitForMultipleObjects返回Office 2013 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()在Office 2013的64位版本中運行良好嗎?或者需要專門爲64位Office完成某些修改?或者我需要註冊不同的DLL?加載項目設置爲任何cpu。

謝謝。

回答

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 
相關問題