Exemple #1
0
        /// <summary>
        /// Start the watcher and begin receiving change notifications.
        /// <remarks>
        /// If the watcher is running, has no effect.
        /// Registration for notifications should be done before this is called.
        /// </remarks>
        /// </summary>
        public void Start()
        {
            if (Running)
            {
                return;
            }

            #region Registration
            ShellNativeMethods.SHChangeNotifyEntry entry = new ShellNativeMethods.SHChangeNotifyEntry();
            entry.recursively = _recursive;

            entry.pIdl = _shellObject.PIDL;

            _registrationId = ShellNativeMethods.SHChangeNotifyRegister(
                _listenerHandle,
                ShellNativeMethods.ShellChangeNotifyEventSource.ShellLevel | ShellNativeMethods.ShellChangeNotifyEventSource.InterruptLevel | ShellNativeMethods.ShellChangeNotifyEventSource.NewDelivery,
                _manager.RegisteredTypes,                  //ShellObjectChangeTypes.AllEventsMask,
                _message,
                1,
                ref entry);

            if (_registrationId == 0)
            {
                throw new Win32Exception(LocalizedMessages.ShellObjectWatcherRegisterFailed);
            }
            #endregion

            Running = true;
        }
		/// <summary>
		/// Start the watcher and begin receiving change notifications.        
		/// <remarks>
		/// If the watcher is running, has no effect.
		/// Registration for notifications should be done before this is called.
		/// </remarks>
		/// </summary>
		public void Start() {
			if (Running) { return; }

			#region Registration
			ShellNativeMethods.SHChangeNotifyEntry entry = new ShellNativeMethods.SHChangeNotifyEntry();
			entry.recursively = _recursive;

			entry.pIdl = _shellObject.PIDL;

			_registrationId = ShellNativeMethods.SHChangeNotifyRegister(
				_listenerHandle,
				ShellNativeMethods.ShellChangeNotifyEventSource.ShellLevel | ShellNativeMethods.ShellChangeNotifyEventSource.InterruptLevel | ShellNativeMethods.ShellChangeNotifyEventSource.NewDelivery,
				 _manager.RegisteredTypes, //ShellObjectChangeTypes.AllEventsMask,
				_message,
				1,
				ref entry);

			if (_registrationId == 0) {
				throw new Win32Exception(LocalizedMessages.ShellObjectWatcherRegisterFailed);
			}
			#endregion

			Running = true;
		}