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); } }
protected virtual bool OnConnect(string topic, CONVCONTEXT context, bool sameInstance) { return(true); }
public static extern IntPtr DdeConnectList(int idInst, IntPtr hszService, IntPtr hszTopic, IntPtr hConvList, ref CONVCONTEXT pCC);