コード例 #1
0
 public void Dispose()
 {
     foreach (IGroup grp in _groups)
     {
         grp.Dispose();
     }
     _groups.Clear();
     Ddeml.DdeDisconnect(hconvCurrent);
 }
コード例 #2
0
        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);
            }
        }
コード例 #3
0
 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();
 }
コード例 #4
0
 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);
     }
 }