コード例 #1
0
ファイル: DDEServer.cs プロジェクト: EDDiscovery/CAPI
        // https://msdn.microsoft.com/en-us/library/ms648742%28v=VS.85%29.aspx?f=255&MSPPError=-2147217396
        private IntPtr DdeCallback(uint uType, uint uFmt, IntPtr hconv, IntPtr hsz1, IntPtr hsz2, IntPtr hdata, UIntPtr dwData1, UIntPtr dwData2)
        {
            DDEMsgType type = (DDEMsgType)uType;

            switch (type)
            {
            case DDEMsgType.XTYP_REGISTER:
                System.Diagnostics.Debug.WriteLine("DDE Register");
                break;

            case DDEMsgType.XTYP_CONNECT:
            {
                foreach (var t in TopicHandles)
                {
                    bool isValid = (NativeMethods.DdeCmpStringHandles(hsz1, t) == 0 &&
                                    NativeMethods.DdeCmpStringHandles(hsz2, ServerNameHandle) == 0);

                    if (isValid)
                    {
                        return(new IntPtr(1));
                    }
                }

                return(new IntPtr(0));
            }

            case DDEMsgType.XTYP_CONNECT_CONFIRM:
                System.Diagnostics.Debug.WriteLine("DDE Connect confirm");
                break;

            case DDEMsgType.XTYP_EXECUTE:
            {
                for (int i = 0; i < TopicHandles.Count; i++)
                {
                    if (hsz1 == TopicHandles[i])
                    {
                        System.Diagnostics.Debug.WriteLine("DDE Execute");
                        TopicActions[i].Invoke(hdata);              // only hdata is of interest https://docs.microsoft.com/en-us/windows/win32/dataxchg/xtyp-execute
                        break;
                    }
                }

                return(new IntPtr((int)DdeResult.DDE_FACK));
            }

            case DDEMsgType.XTYP_DISCONNECT:
                System.Diagnostics.Debug.WriteLine("DDE Disconnect");
                break;

            default:
                System.Diagnostics.Debug.WriteLine($"DDE Unknown {uType:X}");
                break;
            }
            return(IntPtr.Zero);
        }
コード例 #2
0
ファイル: CustomURLResponder.cs プロジェクト: rodan123/EDDI
        // https://msdn.microsoft.com/en-us/library/ms648742%28v=VS.85%29.aspx?f=255&MSPPError=-2147217396
        private IntPtr DdeCallback(uint uType, uint uFmt, IntPtr hconv, IntPtr hsz1, IntPtr hsz2, IntPtr hdata, UIntPtr dwData1, UIntPtr dwData2)
        {
            DDEMsgType type = (DDEMsgType)uType;

            switch (type)
            {
            case DDEMsgType.XTYP_CONNECT:
                bool isValid = (NativeMethods.DdeCmpStringHandles(hsz1, TopicHandle) == 0 &&
                                NativeMethods.DdeCmpStringHandles(hsz2, ServerNameHandle) == 0);
                return(new IntPtr(isValid ? 1 : 0));

            case DDEMsgType.XTYP_EXECUTE:
                string url = FromDdeStringHandle(hdata);
                urlHandler?.Invoke(url);
                return(new IntPtr((int)DdeResult.DDE_FACK));

            default:
                break;
            }
            return(IntPtr.Zero);
        }