public void Dispose() { foreach (IGroup grp in _groups) { grp.Dispose(); } _groups.Clear(); Ddeml.DdeDisconnect(hconvCurrent); }
public unsafe bool Connect() { IntPtr hConv, hszService, hszTopic; if (dwDDEInst != 0) { Ddeml.DdeUninitialize(dwDDEInst); dwDDEInst = 0; } if (hconvCurrent != IntPtr.Zero) { Ddeml.DdeDisconnect(hconvCurrent); hconvCurrent = IntPtr.Zero; } ; //如果是第一次,则什么也不做 Ddeml.DdeInitialize(ref dwDDEInst, _Callback, 0x3f000, 0); // Connect to the server hszTopic = Ddeml.DdeCreateStringHandle(dwDDEInst, _topic, Ddeml.CP_WINANSI); hszService = Ddeml.DdeCreateStringHandle(dwDDEInst, _server, Ddeml.CP_WINANSI); CONVCONTEXT cc = new CONVCONTEXT(); cc.cb = sizeof(CONVCONTEXT); hConv = Ddeml.DdeConnect(dwDDEInst, hszService, hszTopic, ref cc); //int DdeErrcode = Win32.DdeGetLastError(dwDDEInst); Ddeml.DdeFreeStringHandle(dwDDEInst, hszTopic); Ddeml.DdeFreeStringHandle(dwDDEInst, hszService); if (hConv != IntPtr.Zero) { if (hconvCurrent != IntPtr.Zero) { Ddeml.DdeDisconnect(hconvCurrent); } hconvCurrent = hConv; _connected = true; return(true); } else { _connected = false; return(false); } }
public void Disconnect() { if (IsDisposed) { throw new ObjectDisposedException(this.GetType().ToString()); } if (!IsRegistered) { throw new InvalidOperationException("NotRegisteredMessage"); } // Terminate all conversations. foreach (IntPtr hConv in _ConversationTable) { Ddeml.DdeDisconnect(hConv); } // clear the hConv table. _ConversationTable.Clear(); }
public void Disconnect(IntPtr hConv) { if (IsDisposed) { throw new ObjectDisposedException(this.GetType().ToString()); } if (!IsRegistered) { throw new InvalidOperationException("NotRegisteredMessage"); } if (_ConversationTable.Contains(hConv)) { // Terminate the hConv. Ddeml.DdeDisconnect(hConv); // Remove the Conversation from the hConv table. _ConversationTable.Remove(hConv); } }