NDde This contains information about the Disconnected event. This is the base class for all NDde event argument classes. This returns a string containing the current values of all properties. A string containing the current values of all properties. This gets a bool indicating whether the client disconnected because of the server. This gets a bool indicating whether the client disconnected because Dispose was explicitly called. The value will be true if Dispose was explicitly called on DdeClient. The DdeClient sending this event has been disposed and can no longer be accessed. Any exception thrown in the currently executing method will be ignored. This namespace contains classes for using Dynamic Data Exchange (DDE) in .NET. This namespace contains classes for using advanced features of the library. This namespace contains classes for creating DDE monitors. This namespace contains classes for creating DDE client applications. This namespace contains classes for creating DDE server applications. This class is needed to dispose of DDEML resources correctly since the DDEML is thread specific. This class is needed to dispose of DDEML resources correctly since the DDEML is thread specific. This contains information about the CallbackActivity event. This contains information about events on DdeMonitor. This gets the task handle of the application associated with this event. See the MSDN documentation for information about this member. See the MSDN documentation for information about this member. See the MSDN documentation for information about this member. See the MSDN documentation for information about this member. See the MSDN documentation for information about this member. See the MSDN documentation for information about this member. See the MSDN documentation for information about this member. See the MSDN documentation for information about this member. This gets the return value of the DDEML callback function. See the MSDN documentation for information about this member. This represents the client side of a DDE conversation. DDE conversations are established by specifying a service name and topic name pair. The service name is usually the name of the application acting as a DDE server. A DDE server can respond to multiple service names, but most servers usually only respond to one. The topic name is a logical context for data and is defined by the server application. A server can and usually does support many topic names. After a conversation has been established by calling Connect an application can read and write data using the Request and Poke methods respectively by specifying an item name supported by the active conversation. An item name identifies a unit of data. An application can also be notified of changes by initiating an advise loop on an item name using the StartAdvise method. Advise loops can either be warm or hot. A hot advise loop returns the data associated with an item name when it changes whereas a warm advise loop only notifies the application without sending any data. Commands can be sent to the server using the Execute method. Callbacks and events are invoked on the thread hosting the DdeContext. All operations must be marshaled onto the thread hosting the DdeContext associated with this object. Method calls will block until that thread becomes available. An exception will be generated if the thread does not become available in a timely manner. The following example demonstrates how to use a DdeClient. using System; using System.Text; using NDde.Client; public sealed class Client { public static void Main(string[] args) { // Wait for the user to press ENTER before proceding. Console.WriteLine("The Server sample must be running before the client can connect."); Console.WriteLine("Press ENTER to continue..."); Console.ReadLine(); try { // Create a client that connects to 'myapp|mytopic'. using (DdeClient client = new DdeClient("myapp", "mytopic")) { // Subscribe to the Disconnected event. This event will notify the application when a conversation has been terminated. client.Disconnected += OnDisconnected; // Connect to the server. It must be running or an exception will be thrown. client.Connect(); // Synchronous Execute Operation client.Execute("mycommand", 60000); // Synchronous Poke Operation client.Poke("myitem", DateTime.Now.ToString(), 60000); // Syncronous Request Operation Console.WriteLine("Request: " + client.Request("myitem", 60000)); // Asynchronous Execute Operation client.BeginExecute("mycommand", OnExecuteComplete, client); // Asynchronous Poke Operation client.BeginPoke("myitem", Encoding.ASCII.GetBytes(DateTime.Now.ToString() + "\0"), 1, OnPokeComplete, client); // Asynchronous Request Operation client.BeginRequest("myitem", 1, OnRequestComplete, client); // Advise Loop client.StartAdvise("myitem", 1, true, 60000); client.Advise += OnAdvise; // Wait for the user to press ENTER before proceding. Console.WriteLine("Press ENTER to quit..."); Console.ReadLine(); } } catch (Exception e) { Console.WriteLine(e.ToString()); Console.WriteLine("Press ENTER to quit..."); Console.ReadLine(); } } private static void OnExecuteComplete(IAsyncResult ar) { try { DdeClient client = (DdeClient)ar.AsyncState; client.EndExecute(ar); Console.WriteLine("OnExecuteComplete"); } catch (Exception e) { Console.WriteLine("OnExecuteComplete: " + e.Message); } } private static void OnPokeComplete(IAsyncResult ar) { try { DdeClient client = (DdeClient)ar.AsyncState; client.EndPoke(ar); Console.WriteLine("OnPokeComplete"); } catch (Exception e) { Console.WriteLine("OnPokeComplete: " + e.Message); } } private static void OnRequestComplete(IAsyncResult ar) { try { DdeClient client = (DdeClient)ar.AsyncState; byte[] data = client.EndRequest(ar); Console.WriteLine("OnRequestComplete: " + Encoding.ASCII.GetString(data)); } catch (Exception e) { Console.WriteLine("OnRequestComplete: " + e.Message); } } private static void OnStartAdviseComplete(IAsyncResult ar) { try { DdeClient client = (DdeClient)ar.AsyncState; client.EndStartAdvise(ar); Console.WriteLine("OnStartAdviseComplete"); } catch (Exception e) { Console.WriteLine("OnStartAdviseComplete: " + e.Message); } } private static void OnStopAdviseComplete(IAsyncResult ar) { try { DdeClient client = (DdeClient)ar.AsyncState; client.EndStopAdvise(ar); Console.WriteLine("OnStopAdviseComplete"); } catch (Exception e) { Console.WriteLine("OnStopAdviseComplete: " + e.Message); } } private static void OnAdvise(object sender, DdeAdviseEventArgs args) { Console.WriteLine("OnAdvise: " + args.Text); } private static void OnDisconnected(object sender, DdeDisconnectedEventArgs args) { Console.WriteLine( "OnDisconnected: " + "IsServerInitiated=" + args.IsServerInitiated.ToString() + " " + "IsDisposed=" + args.IsDisposed.ToString()); } } // class Imports System.Text Imports NDde.Client Module Program Sub Main() ' Wait for the user to press ENTER before proceding. Console.WriteLine("The Server sample must be running before the client can connect.") Console.WriteLine("Press ENTER to continue...") Console.ReadLine() Try ' Create a client that connects to 'myapp|mytopic'. Using client As DdeClient = New DdeClient("myapp", "mytopic") ' Subscribe to the Disconnected event. This event will notify the application when a conversation has been terminated. AddHandler client.Disconnected, AddressOf OnDisconnected ' Connect to the server. It must be running or an exception will be thrown. client.Connect() ' Synchronous Execute Operation client.Execute("mycommand", 60000) ' Synchronous Poke Operation client.Poke("myitem", DateTime.Now.ToString(), 60000) ' Syncronous Request Operation Console.WriteLine("Request: " + client.Request("myitem", 60000)) ' Asynchronous Execute Operation client.BeginExecute("mycommand", AddressOf OnExecuteComplete, client) ' Asynchronous Poke Operation client.BeginPoke("myitem", Encoding.ASCII.GetBytes(DateTime.Now.ToString() + Convert.ToChar(0)), 1, AddressOf OnPokeComplete, client) ' Asynchronous Request Operation client.BeginRequest("myitem", 1, AddressOf OnRequestComplete, client) ' Advise Loop client.StartAdvise("myitem", 1, True, 60000) AddHandler client.Advise, AddressOf OnAdvise ' Wait for the user to press ENTER before proceding. Console.WriteLine("Press ENTER to quit...") Console.ReadLine() End Using Catch e As Exception Console.WriteLine(e.ToString()) Console.WriteLine("Press ENTER to quit...") Console.ReadLine() End Try End Sub Private Sub OnExecuteComplete(ByVal ar As IAsyncResult) Try Dim client As DdeClient = DirectCast(ar.AsyncState, DdeClient) client.EndExecute(ar) Console.WriteLine("OnExecuteComplete") Catch e As Exception Console.WriteLine("OnExecuteComplete: " + e.Message) End Try End Sub Private Sub OnPokeComplete(ByVal ar As IAsyncResult) Try Dim client As DdeClient = DirectCast(ar.AsyncState, DdeClient) client.EndPoke(ar) Console.WriteLine("OnPokeComplete") Catch e As Exception Console.WriteLine("OnPokeComplete: " + e.Message) End Try End Sub Private Sub OnRequestComplete(ByVal ar As IAsyncResult) Try Dim client As DdeClient = DirectCast(ar.AsyncState, DdeClient) client.EndRequest(ar) Console.WriteLine("OnRequestComplete") Catch e As Exception Console.WriteLine("OnRequestComplete: " + e.Message) End Try End Sub Private Sub OnStartAdviseComplete(ByVal ar As IAsyncResult) Try Dim client As DdeClient = DirectCast(ar.AsyncState, DdeClient) client.EndStartAdvise(ar) Console.WriteLine("OnStartAdviseComplete") Catch e As Exception Console.WriteLine("OnStartAdviseComplete: " + e.Message) End Try End Sub Private Sub OnStopAdviseComplete(ByVal ar As IAsyncResult) Try Dim client As DdeClient = DirectCast(ar.AsyncState, DdeClient) client.EndStopAdvise(ar) Console.WriteLine("OnStopAdviseComplete") Catch e As Exception Console.WriteLine("OnStopAdviseComplete: " + e.Message) End Try End Sub Private Sub OnAdvise(ByVal sender As Object, ByVal args As DdeAdviseEventArgs) Console.WriteLine("OnAdvise: " + args.Text) End Sub Private Sub OnDisconnected(ByVal sender As Object, ByVal args As DdeDisconnectedEventArgs) Console.WriteLine( _ "OnDisconnected: " + _ "IsServerInitiated=" + args.IsServerInitiated.ToString() + " " + _ "IsDisposed=" + args.IsDisposed.ToString()) End Sub End Module This initializes a new instance of the DdeClient class that can connect to a server that supports the specified service name and topic name pair. A service name supported by a server application. A topic name support by a server application. This is thown when servic or topic exceeds 255 characters. This is thrown when service or topic is a null reference. This initializes a new instance of the DdeClient class that can connect to a server that supports the specified service name and topic name pair using the specified synchronizing object. A service name supported by a server application. A topic name support by a server application. The synchronizing object to use for this instance. This is thown when service or topic exceeds 255 characters. This is thrown when service or topic is a null reference. This initializes a new instance of the DdeClient class that can connect to a server that supports the specified service name and topic name pair and uses the specified context. A service name supported by a server application. A topic name support by a server application. The context to use for execution. This is thown when servic or topic exceeds 255 characters. This is thrown when service or topic is a null reference. This terminates the current conversation and releases all resources held by this instance. This contains the implementation to release all resources held by this instance. True if called by Dispose, false otherwise. This establishes a conversation with a server that supports the specified service name and topic name pair. This is thrown when the client is already connected. This is thrown when the client could not connect to the server. This establishes a conversation with a server that supports the specified service name and topic name pair. Zero if the operation succeed or non-zero if the operation failed. This terminates the current conversation. This is thrown when the client was not previously connected. This is thown when the client could not disconnect from the server. This pauses the current conversation. This is thrown when the conversation is already paused. This is thrown when the conversation could not be paused or when the client is not connected. Synchronous operations will timeout if the conversation is paused. Asynchronous operations can begin, but will not complete until the conversation has resumed. This resumes the current conversation. This is thrown when the conversation was not previously paused or when the client is not connected. This is thrown when the conversation could not be resumed. This terminates an asychronous operation. The IAsyncResult object returned by a call that begins an asynchronous operation. This method does nothing if the asynchronous operation has already completed. This is thown when asyncResult is an invalid IAsyncResult. This is thrown when asyncResult is a null reference. This is thrown when the client is not connected. This is thrown when the asynchronous operation could not be abandoned. This sends a command to the server application. The command to be sent to the server application. The amount of time in milliseconds to wait for a response. This is thown when command exceeds 255 characters or timeout is negative. This is thrown when command is a null reference. This is thrown when the client is not connected. This is thrown when the server does not process the command. This operation will timeout if the conversation is paused. This sends a command to the server application. The command to be sent to the server application. The amount of time in milliseconds to wait for a response. Zero if the operation succeed or non-zero if the operation failed. This operation will timeout if the conversation is paused. This begins an asynchronous operation to send a command to the server application. The command to be sent to the server application. The delegate to invoke when this operation completes. An application defined data object to associate with this operation. An IAsyncResult object for this operation. This is thown when command exceeds 255 characters. This is thrown when command is a null reference. This is thrown when the client is not connected. This is thrown when the asynchronous operation could not begin. This throws any exception that occurred during the asynchronous operation. The IAsyncResult object returned by a call to BeginExecute. This is thown when asyncResult is an invalid IAsyncResult. This is thrown when asyncResult is a null reference. This is thrown when the server does not process the command. This sends data to the server application. An item name supported by the current conversation. The data to send. The amount of time in milliseconds to wait for a response. This is thown when item exceeds 255 characters or timeout is negative. This is thrown when item or data is a null reference. This is thrown when the client is not connected. This is thrown when the server does not process the data. This operation will timeout if the conversation is paused. This sends data to the server application. An item name supported by the current conversation. The data to send. The format of the data. The amount of time in milliseconds to wait for a response. This is thown when item exceeds 255 characters or timeout is negative. This is thrown when item or data is a null reference. This is thrown when the client is not connected. This is thrown when the server does not process the data. This operation will timeout if the conversation is paused. This sends data to the server application. An item name supported by the current conversation. The data to send. The format of the data. The amount of time in milliseconds to wait for a response. Zero if the operation succeed or non-zero if the operation failed. This operation will timeout if the conversation is paused. This begins an asynchronous operation to send data to the server application. An item name supported by the current conversation. The data to send. The format of the data. The delegate to invoke when this operation completes. An application defined data object to associate with this operation. An IAsyncResult object for this operation. This is thown when item exceeds 255 characters. This is thrown when item or data is a null reference. This is thrown when the client is not connected. This is thrown when the asynchronous operation could not begin. This throws any exception that occurred during the asynchronous operation. The IAsyncResult object returned by a call to BeginPoke. This is thown when asyncResult is an invalid IAsyncResult. This is thrown when asyncResult is a null reference. This is thrown when the server does not process the data. This requests data using the specified item name. An item name supported by the current conversation. The amount of time in milliseconds to wait for a response. The data returned by the server application in CF_TEXT format. This is thown when item exceeds 255 characters or timeout is negative. This is thrown when item is a null reference. This is thrown when the client is not connected. This is thrown when the server does not process the request. This operation will timeout if the conversation is paused. This requests data using the specified item name. An item name supported by the current conversation. The format of the data to return. The amount of time in milliseconds to wait for a response. The data returned by the server application. This is thown when item exceeds 255 characters or timeout is negative. This is thrown when item is a null reference. This is thrown when the client is not connected. This is thrown when the server does not process the request. This operation will timeout if the conversation is paused. This requests data using the specified item name. An item name supported by the current conversation. The format of the data to return. The amount of time in milliseconds to wait for a response. The data returned by the server application. Zero if the operation succeeded or non-zero if the operation failed. This operation will timeout if the conversation is paused. This begins an asynchronous operation to request data using the specified item name. An item name supported by the current conversation. The format of the data to return. The delegate to invoke when this operation completes. An application defined data object to associate with this operation. An IAsyncResult object for this operation. This is thown when item exceeds 255 characters. This is thrown when item is a null reference. This is thrown when the client is not connected. This is thrown when the asynchronous operation could not begin. This gets the data returned by the server application for the operation. The IAsyncResult object returned by a call to BeginRequest. The data returned by the server application. This is thown when asyncResult is an invalid IAsyncResult. This is thrown when asyncResult is a null reference. This is thrown when the server does not process the request. This initiates an advise loop on the specified item name. An item name supported by the current conversation. The format of the data to return. A bool indicating whether data should be included with the notification. The amount of time in milliseconds to wait for a response. This is thown when item exceeds 255 characters or timeout is negative. This is thrown when item is a null reference. This is thrown when the item is already being advised or when the client is not connected. This is thrown when the server does not initiate the advise loop. This operation will timeout if the conversation is paused. This initiates an advise loop on the specified item name. An item name supported by the current conversation. The format of the data to return. A bool indicating whether data should be included with the notification. A bool indicating whether the client should acknowledge each advisory before the server will send send another. The amount of time in milliseconds to wait for a response. An application defined data object to associate with this advise loop. This is thown when item exceeds 255 characters or timeout is negative. This is thrown when item is a null reference. This is thrown when the item is already being advised or when the client is not connected. This is thrown when the server does not initiate the advise loop. This operation will timeout if the conversation is paused. This begins an asynchronous operation to initiate an advise loop on the specified item name. An item name supported by the current conversation. The format of the data to be returned. A bool indicating whether data should be included with the notification. The delegate to invoke when this operation completes. An application defined data object to associate with this operation. An IAsyncResult object for this operation. This is thown when item exceeds 255 characters. This is thrown when item is a null reference. This is thrown when the item is already being advised or when the client is not connected. This is thrown when the asynchronous operation could not begin. This begins an asynchronous operation to initiate an advise loop on the specified item name. An item name supported by the current conversation. The format of the data to be returned. A bool indicating whether data should be included with the notification. A bool indicating whether the client should acknowledge each advisory before the server will send send another. The delegate to invoke when this operation completes. An application defined data object to associate with this operation. An application defined data object to associate with this advise loop. An IAsyncResult object for this operation. This is thown when item exceeds 255 characters. This is thrown when item is a null reference. This is thrown when the item is already being advised or when the client is not connected. This is thrown when the asynchronous operation could not begin. This throws any exception that occurred during the operation. The IAsyncResult object returned by a call to BeginPoke. This is thown when asyncResult is an invalid IAsyncResult. This is thrown when asyncResult is a null reference. This is thrown when the server does not initiate the advise loop. This terminates the advise loop for the specified item name. An item name that has an active advise loop. The amount of time in milliseconds to wait for a response. This operation will timeout if the conversation is paused. This is thown when item exceeds 255 characters or timeout is negative. This is thrown when item is a null reference. This is thrown when the item is not being advised or when the client is not connected. This is thrown when the server does not terminate the advise loop. This begins an asynchronous operation to terminate the advise loop for the specified item name. An item name that has an active advise loop. The delegate to invoke when this operation completes. An application defined data object to associate with this operation. An IAsyncResult object for this operation. This is thown when item exceeds 255 characters. This is thrown when item is a null reference. This is thrown when the item is not being advised or when the client is not connected. This is thrown when the asynchronous operation could not begin. This throws any exception that occurred during the operation. The IAsyncResult object returned by a call to BeginPoke. This is thown when asyncResult is an invalid IAsyncResult. This is thrown when asyncResult is a null reference. This is thrown when the server does not terminate the advise loop. This is raised when the data has changed for an item name that has an advise loop. This is raised when the client has been disconnected. This gets the context associated with this instance. This gets the service name associated with this conversation. This gets the topic name associated with this conversation. This gets the DDEML handle associated with this conversation. This can be used in any DDEML function requiring a conversation handle. Incorrect usage of the DDEML can cause this object to function incorrectly and can lead to resource leaks. This gets a bool indicating whether this conversation is paused. This gets a bool indicating whether the conversation is established. Do not assume that the conversation is still established after checking this property. The conversation can terminate at any time. This specifies the different kinds of DDE activity that can be monitored. This indicates activity caused by the execution of a DDEML callback. This indicates activity caused by conversation. This indicates activity caused by an error. This indicates activity caused by an advise loop. This indicates activity caused by DDE messages. This is used to monitor DDE activity. This initializes a new instance of the DdeMonitor class. This releases all resources held by this instance. This starts monitoring the system for DDE activity. A bitwise combination of DdeMonitorFlags that indicate what DDE activity will be monitored. This is raised anytime a DDEML callback is executed. This is raised anytime a conversation is established or terminated. This is raised anytime there is an error. This is raised anytime an advise loop is established or terminated. This is raised anytime a DDE message is sent or posted. This gets the context associated with this instance. This contains the parameters of the DDEML callback function. The dwRet property contains the value returned by the DDEML callback function and is the only member that can be modified. See the MSDN documentation for more information about the members of this class. Incorrect usage of the DDEML can cause this library to function incorrectly and can lead to resource leaks. See the MSDN documentation for information about this member. See the MSDN documentation for information about this member. See the MSDN documentation for information about this member. See the MSDN documentation for information about this member. See the MSDN documentation for information about this member. See the MSDN documentation for information about this member. See the MSDN documentation for information about this member. See the MSDN documentation for information about this member. This gets the return value of the DDEML callback function. See the MSDN documentation for information about this member. This will be ignored if the PreFilterTransaction method returns false. This contains information about the Register and Unregister events. This gets the service name associated with this event. This class is needed to dispose of DDEML resources correctly since the DDEML is thread specific. This represents the kind of message contained in DdeMessageActivityEventArgs. The message was posted by a DDE application. The message was sent by a DDE application. This contains information about the MessageActivity event. This gets the kind of message associated with this event. This gets the message associated with this event. This is a synchronizing object that can run a message loop on any thread. This initializes a new instance of the DdeMessageLoop class. This releases all resources held by this instance. This begins an asynchronous operation to execute a delegate on the thread hosting this object. The delegate to execute. The arguments to pass to the delegate. An IAsyncResult object for this operation. This returns the object that the delegate returned in the operation. The IAsyncResult object returned by a call to BeginInvoke. The object returned by the delegate. This executes a delegate on the thread hosting this object. The delegate to execute. The arguments to pass to the delegate. The object returned by the delegate. This starts a message loop on the current thread. This starts a message loop on the current thread and shows the specified form. The Form to display. This gets a bool indicating whether the caller must use Invoke. This represents a DDE conversation established on a DdeServer. This returns a string containing the current values of all properties. A string containing the current values of all properties. This gets the service name associated with this conversation. This gets the topic name associated with this conversation. This gets the DDEML handle associated with this conversation. This can be used in any DDEML function requiring a conversation handle. Incorrect usage of the DDEML can cause this object to function incorrectly and can lead to resource leaks. This gets a bool indicating whether this conversation is paused. This gets an application defined data object associated with this conversation. Use this property to carry state information with the conversation. This defines a transaction filter. Use a transaction filter to intercept the DDEML callback function. The PreFilterTransaction method will be called every time the DDEML callback function executes. The Transaction object passed into the method contains the parameters of the DDE callback function. By using a transaction filter the developer has compelete control over the DDEML. See the MSDN documentation for more information on using the DDEML. Incorrect usage of the DDEML can cause this library to function incorrectly and can lead to resource leaks. This filters a transaction before it is dispatched. The transaction to be dispatched. True to filter the transaction and stop it from being dispatched, false otherwise. This method is called everytime the DDEML callback function executes. Incorrect usage of the DDEML can cause this library to function incorrectly and can lead to resource leaks. This provides an execution context for DdeClient and DdeServer. This class provides a context for DDE activity. All DdeClient and DdeServer objects must be associated with an instance of this class. If one is not specified in their constructors then a default instance of this class is used. This class must be initialized before it can begin sending and receiving DDE messages. This happens automatically upon its first use by a DdeClient or DdeServer. An application can call Initialize to make the initialization process occur immediately. This is useful when a calling application expects this class to raise the Register and Unregister events or invoke the ITransactionFilter.PreFilterTransaction method before being used by a DdeClient or DdeServer. Since forms and controls implement ISynchronizeInvoke they can be used as the synchronizing object for this class. When an instance of this class is created to use a form or control as the synchronizing object it will use the UI thread for execution. This is the preferred way of creating an instance of this class when used in a windows application since it avoids multithreaded synchronization issues and cross thread marshaling. When an instance of this class is created without specifying a synchronizing object it will create and manage its own thread for execution. This is convenient if you wish to use this library in a console or service application, but with the added cost of cross thread marshaling and the potential for deadlocking application threads. Events are invoked on the thread hosting the DdeContext. All operations must be marshaled onto the thread hosting the DdeContext. Method calls will block until that thread becomes available. An exception will be generated if the thread does not become available in a timely manner. The following example demonstrates how to instantiate a DdeContext in a console application. using System; using NDde.Advanced; public class Example { public static void Main() { // Create a context that uses a dedicated thread for DDE message pumping. DdeContext context = new DdeContext(); } } Imports NDde.Advanced Public Class Example Public Shared Sub Main() ' Create a context that uses a dedicated thread for DDE message pumping. Dim context As DdeContext = New DdeContext() End Sub End Class The following example demonstrates how to instantiate a DdeContext in a windows application. using System; using NDde.Advanced; public class Example : Form { // Standard Form code omitted for brevity. private DdeContext context = null; private void Form1_Load(object sender, System.EventArgs e) { // Create a context that uses the UI thread for DDE message pumping. context = new DdeContext(this); } } Imports NDde.Advanced Public Class Example Inherits Form Private context as DdeContext = Nothing Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) ' Create a context that uses the UI thread for DDE message pumping. context = New DdeContext(Me) End Sub End Class This initializes a new instance of the DdeContext class that uses a dedicated thread for execution. This constructor is used when you want the context to create and manage its own thread for DDE message pumping. This initializes a new instance of the DdeContext class that uses the specified synchronizing object for execution. The synchronizing object to use for execution. This is thrown when synchronizer is a null reference. This constructor is used when you want the context to use the specified synchronizing object for DDE message pumping. Since forms and controls implement ISynchronizeInvoke they can be used as the synchronizing object. In that case the windows application UI thread that is hosting the form or control is used. This releases all resources held by this instance. This initializes the context. This is thrown when the context is already initialized. This is thrown when the context could not be initialized. This class must be initialized before it can begin sending and receiving DDE messages. This happens automatically upon its first use by a DdeClient or DdeServer. An application can call Initialize to make the initialization process occur immediately. This is useful when a calling application expects this class to raise the Register and Unregister events or invoke the ITransactionFilter.PreFilterTransaction method before being used by a DdeClient or DdeServer. If you attempt to use a synchronizer that is not hosted on a thread running a windows message loop an exception will be thrown. Explicitly calling this method will allow added ITransactionFilter objects to begin intercepting the DDEML callback function. This adds a transaction filter to monitor DDE transactions. The implementation of ITransactionFilter that you want to add. This is thrown when filter is a null reference. This is thrown when the filter was already added. Transaction filters can be used to intercept the DDEML callback. Incorrect usage of the DDEML can cause this library to function incorrectly and can lead to resource leaks. This removes a transaction filter and stops it from monitoring DDE transactions. The implementation of ITransactionFilter that you want to remove. This is thrown when filter is a null reference. This is thrown when the filter was not previously added. Transaction filters can be used to intercept the DDEML callback. Incorrect usage of the DDEML can cause this library to function incorrectly and can lead to resource leaks. This executes a ThreadStart delegate on the thread hosting this object. The delegate to execute. This executes a delegate on the thread hosting this object. The delegate to execute. The arguments to pass to the delegate. The object returned by the delegate. This begins an asynchronous operation to execute a delegate on the thread hosting this object. The delegate to execute. The arguments to pass to the delegate. An IAsyncResult object for this operation. This returns the object that the delegate returned in the operation. The IAsyncResult object returned by a call to BeginInvoke. The object returned by the delegate. This is raised when a service name has been registered by a server using the DDEML. This event will not be raised by servers that do not use the DDEML. This is raised when a service name has been unregistered by a server using the DDEML. This event will not be raised by servers that do not use the DDEML. This gets the DDEML instance identifier. This can be used in any DDEML function requiring an instance identifier. Incorrect usage of the DDEML can cause this library to function incorrectly and can lead to resource leaks. This gets a bool indicating whether the context is initialized. This gets or sets the default encoding that is used. This gets a bool indicating whether the caller must use Invoke. This contains information about the ErrorActivity event. This gets an error code returned by the DDEML. This contains information about the ConversationActivity event. This gets the service name associated with the conversation. This gets the topic name associated with the conversation. This gets a bool indicating whether the conversation is being established. The value returned by this property will be true if the conversation is being established. If the conversation is being terminated then the value will be false. This gets the handle to the client application associated with the conversation. This gets the handle to the server application associated with the conversation. A strongly-typed resource class, for looking up localized strings, etc. Returns the cached ResourceManager instance used by this class. Overrides the current thread's CurrentUICulture property for all resource lookups using this strongly typed resource class. Looks up a localized string similar to The server failed to advise "${service}|${topic}!${item}".. Looks up a localized string similar to An advise loop for "${service}|${topic}!${item}" already exists.. Looks up a localized string similar to The client is already connected.. Looks up a localized string similar to The context is already intialized.. Looks up a localized string similar to The specified conversation is already paused.. Looks up a localized string similar to The service is already registered.. Looks up a localized string similar to The IAsyncResult must have been returned by a call to ${method}.. Looks up a localized string similar to The client failed to pause the conversation.. Looks up a localized string similar to The client failed to resume the conversation.. Looks up a localized string similar to The client failed to connect to "${service}|${topic}". Make sure the server application is running and that it supports the specified service name and topic name pair.. Looks up a localized string similar to The client failed to execute "${command}".. Looks up a localized string similar to The transaction filter has already been added.. Looks up a localized string similar to The transaction filter has not been added.. Looks up a localized string similar to The context failed to initialize.. Looks up a localized string similar to The context timed out attempting to marshal the operation.. Looks up a localized string similar to The context is not hosted on a thread with a message loop.. Looks up a localized string similar to An advise loop for "${service}|${topic}!${item}" does not exist.. Looks up a localized string similar to The client is not connected.. Looks up a localized string similar to The context is not initialized.. Looks up a localized string similar to The specified conversation is not paused.. Looks up a localized string similar to The service is not registered.. Looks up a localized string similar to The client failed to poke "${service}|${topic}!${item}".. Looks up a localized string similar to The server failed to register "${service}".. Looks up a localized string similar to The client failed to request "${service}|${topic}!${item}".. Looks up a localized string similar to The server failed to pause all conversations.. Looks up a localized string similar to The server failed to pause the specified conversation.. Looks up a localized string similar to The server failed to resume all conversations.. Looks up a localized string similar to The server failed to resume the specified conversation.. Looks up a localized string similar to The client failed to initiate an advise loop for "${service}|${topic}!${item}".. Looks up a localized string similar to The client failed to terminate the advise loop for "${service}|${topic}!${item}".. Looks up a localized string similar to The parameter must be <= 255 characters.. Looks up a localized string similar to The parameter must be > 0.. Looks up a localized string similar to An unknown error occurred.. This is thrown when a DDE exception occurs. This gets an error code returned by the DDEML. The value is zero if the exception was not thrown because of the DDEML. 0x0000DMLERR_NO_DMLERROR 0x4000DMLERR_ADVACKTIMEOUT 0x4001DMLERR_BUSY 0x4002DMLERR_DATAACKTIMEOUT 0x4003DMLERR_DLL_NOT_INITIALIZED 0x4004DMLERR_DLL_USAGE 0x4005DMLERR_EXECACKTIMEOUT 0x4006DMLERR_INVALIDPARAMETER 0x4007DMLERR_LOW_MEMORY 0x4008DMLERR_MEMORY_DMLERROR 0x4009DMLERR_NOTPROCESSED 0x400ADMLERR_NO_CONV_ESTABLISHED 0x400BDMLERR_POKEACKTIMEOUT 0x400CDMLERR_POSTMSG_FAILED 0x400DDMLERR_REENTRANCY 0x400EDMLERR_SERVER_DIED 0x400FDMLERR_SYS_DMLERROR 0x4010DMLERR_UNADVACKTIMEOUT 0x4011DMLERR_UNFOUND_QUEUE_ID This contains information about the LinkActivity event. This gets the service name associated with the link. This gets the topic name associated with the link. This gets the item name associated with the link. This gets the format of the data associated with the link. This gets a bool indicating whether the link is hot. This gets a bool indicating whether the link is being established. The value returned by this property will be true if the conversation is being established. If the conversation is being terminated then the value will be false. This gets a bool indicating whether the link was terminated by the server. This gets the handle to the client application associated with the link. This gets the handle to the server application associated with the link. This represents the server side of DDE conversations. DDE conversations are established by specifying a service name and topic name pair. The service name is usually the name of the application acting as a DDE server. A DDE server can respond to multiple service names, but most servers usually only respond to one. The topic name is a logical context for data and is defined by the server application. A server can and usually does support many topic names. After this object has registered its service name by calling the Register method clients can connect to it by specifying the service name the server registered and a topic name that it supports. Event methods are invoked on the thread hosting the DdeContext. All operations must be marshaled onto the thread hosting the DdeContext associated with this object. Method calls will block until that thread becomes available. An exception will be generated if the thread does not become available in a timely manner. The event methods must be overridden in a subclass as needed. The following example demostrates how to use a DdeServer. using System; using System.Collections; using System.Timers; using NDde.Server; public class Server { public static void Main() { try { // Create a server that will register the service name 'myapp'. using (DdeServer server = new MyServer("myapp")) { // Register the service name. server.Register(); // Wait for the user to press ENTER before proceding. Console.WriteLine("Press ENTER to quit..."); Console.ReadLine(); } } catch (Exception e) { Console.WriteLine(e); Console.WriteLine("Press ENTER to quit..."); Console.ReadLine(); } } private sealed class MyServer : DdeServer { private System.Timers.Timer _Timer = new System.Timers.Timer(); public MyServer(string service) : base(service) { // Create a timer that will be used to advise clients of new data. _Timer.Elapsed += this.OnTimerElapsed; _Timer.Interval = 1000; _Timer.SynchronizingObject = this.Context; _Timer.Start(); } private void OnTimerElapsed(object sender, ElapsedEventArgs args) { // Advise all topic name and item name pairs. Advise("*", "*"); } protected override bool OnBeforeConnect(string topic) { Console.WriteLine("OnBeforeConnect:".PadRight(16) + " Service='" + base.Service + "'" + " Topic='" + topic + "'"); return true; } protected override void OnAfterConnect(DdeConversation conversation) { Console.WriteLine("OnAfterConnect:".PadRight(16) + " Service='" + conversation.Service + "'" + " Topic='" + conversation.Topic + "'" + " Handle=" + conversation.Handle.ToString()); } protected override void OnDisconnect(DdeConversation conversation) { Console.WriteLine("OnDisconnect:".PadRight(16) + " Service='" + conversation.Service + "'" + " Topic='" + conversation.Topic + "'" + " Handle=" + conversation.Handle.ToString()); } protected override bool OnStartAdvise(DdeConversation conversation, string item, int format) { Console.WriteLine("OnStartAdvise:".PadRight(16) + " Service='" + conversation.Service + "'" + " Topic='" + conversation.Topic + "'" + " Handle=" + conversation.Handle.ToString() + " Item='" + item + "'" + " Format=" + format.ToString()); // Initiate the advisory loop only if the format is CF_TEXT. return format == 1; } protected override void OnStopAdvise(DdeConversation conversation, string item) { Console.WriteLine("OnStopAdvise:".PadRight(16) + " Service='" + conversation.Service + "'" + " Topic='" + conversation.Topic + "'" + " Handle=" + conversation.Handle.ToString() + " Item='" + item + "'"); } protected override ExecuteResult OnExecute(DdeConversation conversation, string command) { Console.WriteLine("OnExecute:".PadRight(16) + " Service='" + conversation.Service + "'" + " Topic='" + conversation.Topic + "'" + " Handle=" + conversation.Handle.ToString() + " Command='" + command + "'"); // Tell the client that the command was processed. return ExecuteResult.Processed; } protected override PokeResult OnPoke(DdeConversation conversation, string item, byte[] data, int format) { Console.WriteLine("OnPoke:".PadRight(16) + " Service='" + conversation.Service + "'" + " Topic='" + conversation.Topic + "'" + " Handle=" + conversation.Handle.ToString() + " Item='" + item + "'" + " Data=" + data.Length.ToString() + " Format=" + format.ToString()); // Tell the client that the data was processed. return PokeResult.Processed; } protected override RequestResult OnRequest(DdeConversation conversation, string item, int format) { Console.WriteLine("OnRequest:".PadRight(16) + " Service='" + conversation.Service + "'" + " Topic='" + conversation.Topic + "'" + " Handle=" + conversation.Handle.ToString() + " Item='" + item + "'" + " Format=" + format.ToString()); // Return data to the client only if the format is CF_TEXT. if (format == 1) { return new RequestResult(System.Text.Encoding.ASCII.GetBytes("Time=" + DateTime.Now.ToString() + "\0")); } return RequestResult.NotProcessed; } protected override byte[] OnAdvise(string topic, string item, int format) { Console.WriteLine("OnAdvise:".PadRight(16) + " Service='" + this.Service + "'" + " Topic='" + topic + "'" + " Item='" + item + "'" + " Format=" + format.ToString()); // Send data to the client only if the format is CF_TEXT. if (format == 1) { return System.Text.Encoding.ASCII.GetBytes("Time=" + DateTime.Now.ToString() + "\0"); } return null; } } // class } // class Imports NDde.Server Module Program Sub Main() Try ' Create a server that will register the service name 'myapp'. Using server As DdeServer = New MyServer("myapp") ' Register the service name. server.Register() ' Wait for the user to press ENTER before proceding. Console.WriteLine("Press ENTER to quit...") Console.ReadLine() End Using Catch e As Exception Console.WriteLine(e) Console.WriteLine("Press ENTER to quit...") Console.ReadLine() End Try End Sub Private Class MyServer Inherits DdeServer Private WithEvents theTimer As System.Timers.Timer = New System.Timers.Timer() Public Sub New(ByVal service As String) MyBase.New(service) ' Create a timer that will be used to advise clients of new data. theTimer.Interval = 1000 theTimer.SynchronizingObject = Me.Context theTimer.Start() End Sub Private Sub theTimer_Elapsed(ByVal sender As Object, ByVal e As System.Timers.ElapsedEventArgs) Handles theTimer.Elapsed Me.Advise("*", "*") End Sub Protected Overrides Function OnBeforeConnect(ByVal topic As String) As Boolean Console.WriteLine("OnBeforeConnect:".PadRight(16) _ + " Service='" + MyBase.Service + "'" _ + " Topic='" + topic + "'") Return True End Function Protected Overrides Sub OnAfterConnect(ByVal conversation As DdeConversation) Console.WriteLine("OnAfterConnect:".PadRight(16) _ + " Service='" + conversation.Service + "'" _ + " Topic='" + conversation.Topic + "'" _ + " Handle=" + conversation.Handle.ToString()) End Sub Protected Overrides Sub OnDisconnect(ByVal conversation As DdeConversation) Console.WriteLine("OnDisconnect:".PadRight(16) _ + " Service='" + conversation.Service + "'" _ + " Topic='" + conversation.Topic + "'" _ + " Handle=" + conversation.Handle.ToString()) End Sub Protected Overrides Function OnStartAdvise(ByVal conversation As DdeConversation, ByVal item As String, ByVal format As Integer) As Boolean Console.WriteLine("OnStartAdvise:".PadRight(16) _ + " Service='" + conversation.Service + "'" _ + " Topic='" + conversation.Topic + "'" _ + " Handle=" + conversation.Handle.ToString() _ + " Item='" + item + "'" _ + " Format=" + format.ToString()) ' Initiate the advisory loop only if the format is CF_TEXT. Return format = 1 End Function Protected Overrides Sub OnStopAdvise(ByVal conversation As DdeConversation, ByVal item As String) Console.WriteLine("OnStopAdvise:".PadRight(16) _ + " Service='" + conversation.Service + "'" _ + " Topic='" + conversation.Topic + "'" _ + " Handle=" + conversation.Handle.ToString() _ + " Item='" + item + "'") End Sub Protected Overrides Function OnExecute(ByVal conversation As DdeConversation, ByVal command As String) As ExecuteResult Console.WriteLine("OnExecute:".PadRight(16) _ + " Service='" + conversation.Service + "'" _ + " Topic='" + conversation.Topic + "'" _ + " Handle=" + conversation.Handle.ToString() _ + " Command='" + command + "'") ' Tell the client that the command was processed. Return ExecuteResult.Processed End Function Protected Overrides Function OnPoke(ByVal conversation As DdeConversation, ByVal item As String, ByVal data As Byte(), ByVal format As Integer) As PokeResult Console.WriteLine("OnPoke:".PadRight(16) _ + " Service='" + conversation.Service + "'" _ + " Topic='" + conversation.Topic + "'" _ + " Handle=" + conversation.Handle.ToString() _ + " Item='" + item + "'" _ + " Data=" + data.Length.ToString() _ + " Format=" + format.ToString()) ' Tell the client that the data was processed. Return PokeResult.Processed End Function Protected Overrides Function OnRequest(ByVal conversation As DdeConversation, ByVal item As String, ByVal format As Integer) As RequestResult Console.WriteLine("OnRequest:".PadRight(16) _ + " Service='" + conversation.Service + "'" _ + " Topic='" + conversation.Topic + "'" _ + " Handle=" + conversation.Handle.ToString() _ + " Item='" + item + "'" _ + " Format=" + format.ToString()) ' Return data to the client only if the format is CF_TEXT. If format = 1 Then Return New RequestResult(System.Text.Encoding.ASCII.GetBytes("Time=" + DateTime.Now.ToString() + Convert.ToChar(0))) End If Return RequestResult.NotProcessed End Function Protected Overrides Function OnAdvise(ByVal topic As String, ByVal item As String, ByVal format As Integer) As Byte() Console.WriteLine("OnAdvise:".PadRight(16) _ + " Service='" + Me.Service + "'" _ + " Topic='" + topic + "'" _ + " Item='" + item + "'" _ + " Format=" + format.ToString()) ' Send data to the client only if the format is CF_TEXT. If format = 1 Then Return System.Text.Encoding.ASCII.GetBytes("Time=" + DateTime.Now.ToString() + Convert.ToChar(0)) End If Return Nothing End Function End Class End Module This initializes a new instance of the DdeServer class that can register the specified service name. The service name that this instance can register. This is thown when service exceeds 255 characters.. This is thrown when service is a null reference. This initializes a new instance of the DdeServer class that can register the specified service name and using the specified synchronizing object. The service name that this instance can register. The synchronizing object to use for this instance. This is thown when service exceeds 255 characters.. This is thrown when service is a null reference. This initializes a new instance of the DdeServer class that can register the specified service name and uses the specified context. The service name that this instance can register. The context to use for execution. This is thown when service exceeds 255 characters.. This is thrown when service is a null reference. This unregisters service name and releases all resources held by this instance. This contains the implementation to release all resources held by this instance. True if called by Dispose, false otherwise. This registers the service name. This is thrown when the server is already registered. This is thrown when the service name could not be registered. This unregisters the service name. This is thrown when the server is not registered. This notifies all clients that data has changed for the specified topic name and item name pair. A topic name supported by this server. An item name supported by this server. This is thown when topic or item exceeds 255 characters.. This is thrown when topic or item is a null reference. This is thrown when the server is not registered. This is thrown when the notification could not be posted. Use an asterix to indicate that the topic name, item name, or both should be wild. Pausing a conversation causes this server to queue events until the conversation resumes. This pauses the specified conversation. The conversation to pause. This is thrown when conversation is a null reference. This is thrown when the conversation is already paused or when the server is not registered. This is thrown when the conversation could not be paused. This pauses all conversations. This is thrown when the server is not registered. This is thrown when the conversations could not be paused. Pausing a conversation causes this object to queue events until the conversation resumes. This resumes the specified conversation. The conversation to resume. This is thrown when conversation is a null reference. This is thrown when the conversation is not paused or when the server is not registered. This is thrown when the conversation could not be resumed. This resumes all conversations. This is thrown when the server is not registered. This is thrown when the conversations could not be resumed. This terminates the specified conversation. The conversation to terminate. This is thrown when conversation is a null reference. This is thrown when the server is not registered. This is thrown when the conversation could not be terminated. This terminates all conversations. This is thrown when the server is not registered. This is thrown when the conversations could not be terminated. This is invoked when a client attempts to initiate an advise loop. The conversation associated with this event. The item name associated with this event. The format of the data. True to allow the advise loop, false otherwise. The default implementation accepts all advise loops. This is invoked when a client terminates an advise loop. The conversation associated with this event. The item name associated with this event. This is invoked when a client attempts to establish a conversation. The topic name associated with this event. True to allow the connection, false otherwise. The default implementation accepts all connections. This is invoked when a client has successfully established a conversation. The conversation associated with this event. This is invoked when a client terminates a conversation. The conversation associated with this event. This is invoked when a client sends a command. The conversation associated with this event. The command to be executed. An ExecuteResult indicating the result. The default implementation returns ExecuteResult.NotProcessed to the client. This is invoked when a client sends data. The conversation associated with this event. The item name associated with this event. The data associated with this event. The format of the data. A PokeResult indicating the result. The default implementation returns PokeResult.NotProcessed to the client. This is invoked when a client attempts to request data. The conversation associated with this event. The item name associated with this event. The format of the data. A RequestResult indicating the result. The default implementation returns RequestResult.NotProcessed to the client. This is invoked when the server is performing a hot advise. The topic name associated with this event. The item name associated with this event. The format of the data. The data that will be sent to the clients. The default implementation sends nothing to the clients. This gets the context associated with his instance. This gets the service name associated with this server. This gets a bool indicating whether the service name is registered. This is the return value of the OnExecute method. Return this value if the command was executed successfully. Return this value if the command was not executed successfully. Return this value if the server is too busy. Return this value to pause the conversation and execute the command asynchronously. After the conversation has been resumed the OnExecute method will run again. This determines whether two object instances are equal. The object to compare with the current object. True if the specified object is equal to the current object, false otherwise. This returns a hash code for the object. A hash code for the object. This determines whether two ExecuteResult objects are equal. The left hand side object. The right hand side object. True if the two objects are equal, false otherwise. This determines whether two ExecuteResult objects are not equal. The left hand side object. The right hand side object. True if the two objects are not equal, false otherwise. This is the return value of the OnPoke method. Return this value if the poke was successful. Return this value if the poke was not successful. Return this value if the server is too busy. Return this value to pause the conversation and execute the poke asynchronously. After the conversation has been resumed the OnPoke method will run again. This determines whether two object instances are equal. The object to compare with the current object. True if the specified object is equal to the current object, false otherwise. This returns a hash code for the object. A hash code for the object. This determines whether two PokeResult objects are equal. The left hand side object. The right hand side object. True if the two objects are equal, false otherwise. This determines whether two ExecuteResult objects are not equal. The left hand side object. The right hand side object. True if the two objects are not equal, false otherwise. This is the return value of the OnRequest method. Return this value if the request was not successful. Return this value to pause the conversation and execute the request asynchronously. After the conversation has been resumed the OnRequest method will run again. This initializes the RequestResult struct with the data to return to the client. The data to return to the client. This determines whether two object instances are equal. The object to compare with the current object. True if the specified object is equal to the current object, false otherwise. This returns a hash code for the object. A hash code for the object. This determines whether two RequestResult objects are equal. The left hand side object. The right hand side object. True if the two objects are equal, false otherwise. This determines whether two ExecuteResult objects are not equal. The left hand side object. The right hand side object. True if the two objects are not equal, false otherwise. The data to send to the client application. This contains information about the Advise event. This gets the item name associated with this notification. This gets the format of the data included in this notification. This gets an application defined data object associated with this advise loop. This gets the data associated with this notification or null if this is not a hot advise loop. This gets the text associated with this notification or null if this is not a hot advise loop.