Beispiel #1
0
 public string Register(string service)
 {
     if (IsRegistered || _InstanceId != 0)
     {
         throw new InvalidOperationException("AlreadyRegisteredMessage");
     }
     if (service == null || service.Length > Ddeml.MAX_STRING_SIZE)
     {
         throw new ArgumentNullException("service");
     }
     _Service = service;
     _ConversationTable.Clear();
     _InstanceId    = Initialize(Ddeml.APPCLASS_STANDARD);
     _ServiceHandle = Ddeml.DdeCreateStringHandle(_InstanceId, _Service, Ddeml.CP_WINANSI);
     // Register the service name.
     if (Ddeml.DdeNameService(_InstanceId, _ServiceHandle, IntPtr.Zero, Ddeml.DNS_REGISTER) == IntPtr.Zero)
     {
         Ddeml.DdeFreeStringHandle(_InstanceId, _ServiceHandle);
         _ServiceHandle = IntPtr.Zero;
     }
     // If the service handle is null then the service name could not be registered.
     if (_ServiceHandle == IntPtr.Zero)
     {
         int error = Ddeml.DdeGetLastError(_InstanceId);
         return(Ddeml.DDEGetErrorMsg(error));
     }
     return(null);
 }
Beispiel #2
0
        public void Advise(string topic, string item)
        {
            if (IsDisposed)
            {
                throw new ObjectDisposedException(this.GetType().ToString());
            }
            if (!IsRegistered)
            {
                throw new InvalidOperationException("NotRegisteredMessage");
            }
            if (topic == null || topic.Length > Ddeml.MAX_STRING_SIZE)
            {
                throw new ArgumentNullException("topic");
            }
            if (item == null || item.Length > Ddeml.MAX_STRING_SIZE)
            {
                throw new ArgumentNullException("item");
            }
            // Assume the topic name and item name are wild.
            IntPtr topicHandle = topic != "*" ? Ddeml.DdeCreateStringHandle(_InstanceId, topic, Ddeml.CP_WINANSI) : IntPtr.Zero;
            IntPtr itemHandle  = item != "*" ? Ddeml.DdeCreateStringHandle(_InstanceId, item, Ddeml.CP_WINANSI) : IntPtr.Zero;

            // Check the result to see if the post failed.
            if (!Ddeml.DdePostAdvise(_InstanceId, topicHandle, itemHandle))
            {
                int error = Ddeml.DdeGetLastError(_InstanceId);
                var msg   = Ddeml.DDEGetErrorMsg(error); if (msg != null)
                {
                }
            }
            Ddeml.DdeFreeStringHandle(_InstanceId, itemHandle);
            Ddeml.DdeFreeStringHandle(_InstanceId, topicHandle);
        }
Beispiel #3
0
 public void Resume(IntPtr hConv)
 {
     if (IsDisposed)
     {
         throw new ObjectDisposedException(this.GetType().ToString());
     }
     if (!IsRegistered)
     {
         throw new InvalidOperationException("NotRegisteredMessage");
     }
     // Check the result to see if the DDEML callback was enabled.
     if (!Ddeml.DdeEnableCallback(_InstanceId, hConv, Ddeml.EC_ENABLEALL))
     {
         int error = Ddeml.DdeGetLastError(_InstanceId);
         Ddeml.DDEGetErrorMsg(error);
     }
 }