0

私の会社には、Office 2007 および 2010 で問題なく動作する Office アドインがあります。現在、Microsoft には新しい Office 2013 があります。Office 2013 (32 ビットおよび 64 ビット) でアドインをテストする必要があります。

ほとんどの関数は正常に動作していますが、MsgWaitForMultipleObjects() を使用する関数が 1 つあり、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 に設定されます。

ありがとう。

4

1 に答える 1

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
于 2013-02-04T02:59:22.627 に答える