DDE Conversation Can Cause Error Message: DDE Channel Locked

Last reviewed: June 21, 1995
Article ID: Q95462
The information in this article applies to:

- Standard and Professional Editions of Microsoft Visual Basic for

  Windows, versions 2.0 and 3.0
- Microsoft Visual Basic programming system for Windows, version 1.0

SUMMARY

The error message "DDE channel locked" indicates that an attempt is being made to open a DDE conversation between two objects that are already engaged in a conversation. However, usually the error message occurs in a Visual Basic application as a result of a non-Visual Basic DDE Server application failing to post or send a DDE message Visual Basic is expecting.

The best overall solution is to alter the DDE server application so that it correctly sends the appropriate DDE messages.

Both "DDE channel locked" and "Timeout while waiting for DDE response" are errors that can be trapped in Visual Basic, so you can work around the problem by performing the following steps:

  1. Turn on error trapping. For example:

          On Local Error GoTo DDEerrhand:
    

  2. In your error handling routine, trap error #284 ("DDE channel locked") and set the LinkTimeout property to 1. This triggers the error message "Timeout while waiting for DDE response" much quicker.

  3. Also, in your error handling routine trap error #286 ("Timeout while waiting for DDE response"), reset the LinkTimeout value, re-establish the link, and execute a RESUME statement, as in this example:

          DDEerrhand:
          Select Case Err
    
             Case 284:
                OldLinkMode = Text1.LinkMode
                OldTimeout = Text1.LinkTimeout
                Text1.LinkTimeout = 1
                Resume
             Case 286:
                Text1.LinkTimeout = OldTimeout
                Text1.LinkMode = 0
                Text1.LinkMode = OldLinkMode
                Resume
           End Select
    
    

MORE INFORMATION

The DDE conversation guidelines set by the Windows Software Development Kit (SDK) require that Visual Basic sometimes wait for an expected DDE message. If that message is never correctly sent or posted to Visual Basic, the following scenario is likely to occur, leading to the error message "DDE channel locked":

  1. At some point between when Visual Basic established the conversation and the conversation terminated, the DDE server application fails to post or send a message that Visual Basic is expecting as a normal part of the DDE termination procedure.

  2. At this point, Visual Basic is in a PeekMessage loop waiting for a message from the server indicating that the server application has also terminated the DDE conversation. Because Visual Basic is yielding the CPU inside the loop, the Visual Basic code continues to execute and the DDE conversation appears to have terminated normally from the server side.

  3. Because Visual Basic is still waiting for the expected DDE message from the server application, the DDE channel is still open. Any attempt to reopen the channel (such as setting the LinkMode property for the control performing the DDE) results in a "DDE channel locked" error.

If no further DDE actions are attempted, you will receive a "Timeout while waiting for DDE response" error message. The timeout will occur after a number of milliseconds equal to the communicating control's LinkTimeout property.


Additional reference words: 1.00 2.00 3.00 errmsg
KBCategory: kbinterop kbprg
KBSubcategory: IAPDDE


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: June 21, 1995
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.