Exemplo n.º 1
0
        /// <summary>
        /// Return S_OK (0) so that IE will stop to download the file itself. 
        /// Else the default download user interface is used.
        /// </summary>
        public int Download(IMoniker pmk, IBindCtx pbc, uint dwBindVerb, int grfBINDF, 
            IntPtr pBindInfo, string pszHeaders, string pszRedir, uint uiCP)
        {
            // Get the display name of the pointer to an IMoniker interface that specifies
            // the object to be downloaded.
            string name = string.Empty;
            pmk.GetDisplayName(pbc, null, out name);

            if (!string.IsNullOrEmpty(name))
            {
                Uri url = null;
                bool result = Uri.TryCreate(name, UriKind.Absolute, out url);

                if (result)
                {
                    MessageBox.Show(url.ToString());
                    //pmk.BindToStorage(pbc,null,);

                    //// Launch CSWebDownloader.exe to download the file.
                    //FileInfo assemblyFile =
                    //    new FileInfo(Assembly.GetExecutingAssembly().Location);
                    //ProcessStartInfo start = new ProcessStartInfo
                    //{
                    //    Arguments = name,
                    //    FileName =
                    //    string.Format("{0}\\CSWebDownloader.exe", assemblyFile.DirectoryName)
                    //};
                    //Process.Start(start);
                    return 0;
                }
            }
            return 1;
        }
Exemplo n.º 2
0
 void IMoniker.BindToStorage(IBindCtx pbc, IMoniker pmkToLeft, ref Guid riid, out object ppvObj)
 {
     ppvObj = null;
     if (riid.Equals(Iid_Clsids.IID_IStream))
     {
         ppvObj = this.m_stream;
     }
 }
 internal static extern int FindMimeFromData(
                 IBindCtx pBC,                   // bind context - can be NULL
                 string wszUrl,                  // url - can be null
                 IntPtr Buffer,                  // buffer with data to sniff -
                                                 // can be null (pwzUrl must be valid)
                 int cbSize,                     // size of buffer
                 string wzMimeProposed,          // proposed mime if - can be null
                 int dwMimeFlags,                // will be determined
                 out string wzMimeOut,           // the suggested mime
                 int dwReserved);
        // Token: 0x0600001E RID: 30 RVA: 0x000022AC File Offset: 0x000004AC
        public static object CreateFilter(string filterMoniker)
        {
            object   result  = null;
            IBindCtx bindCtx = null;
            IMoniker moniker = null;
            int      num     = 0;

            if (Win32.CreateBindCtx(0, out bindCtx) == 0)
            {
                if (Win32.MkParseDisplayName(bindCtx, filterMoniker, ref num, out moniker) == 0)
                {
                    Guid guid = typeof(IBaseFilter).GUID;
                    moniker.BindToObject(null, null, ref guid, out result);
                    Marshal.ReleaseComObject(moniker);
                }
                Marshal.ReleaseComObject(bindCtx);
            }
            return(result);
        }
Exemplo n.º 5
0
 private bool IsMatchingMonikerName(IMoniker moniker, IBindCtx bindCtx)
 {
     try
     {
         string name;
         moniker.GetDisplayName(bindCtx, null, out name);
         return(!string.IsNullOrWhiteSpace(name) &&
                name.StartsWith("!VisualStudio.DTE") &&
                name.EndsWith(":" + _devEnvProcess.Id));
     }
     catch (NotImplementedException)
     {
         return(false);
     }
     catch (COMException)
     {
         return(false);
     }
 }
Exemplo n.º 6
0
        public static object CreateFilter(string filterMoniker)
        {
            object   ppvResult = null;
            IBindCtx ppbc      = null;
            IMoniker ppmk      = null;
            int      pchEaten  = 0;

            if (Win32.CreateBindCtx(0, out ppbc) == 0)
            {
                if (Win32.MkParseDisplayName(ppbc, filterMoniker, ref pchEaten, out ppmk) == 0)
                {
                    Guid riidResult = typeof(IBaseFilter).GUID;
                    ppmk.BindToObject(null, null, ref riidResult, out ppvResult);
                    Marshal.ReleaseComObject(ppmk);
                }
                Marshal.ReleaseComObject(ppbc);
            }
            return(ppvResult);
        }
Exemplo n.º 7
0
        public static IBaseFilter AddFilterByDevicePath(IGraphBuilder graphBuilder, string devicePath, string name)
        {
            int         hr      = 0;
            IBaseFilter filter  = null;
            IBindCtx    bindCtx = null;
            IMoniker    moniker = null;
            int         eaten;

            if (graphBuilder == null)
            {
                throw new ArgumentNullException("graphBuilder");
            }

            try
            {
                hr = NativeMethods.CreateBindCtx(0, out bindCtx);
                Marshal.ThrowExceptionForHR(hr);

                hr = NativeMethods.MkParseDisplayName(bindCtx, devicePath, out eaten, out moniker);
                Marshal.ThrowExceptionForHR(hr);

                hr = (graphBuilder as IFilterGraph2).AddSourceFilterForMoniker(moniker, bindCtx, name, out filter);
                DsError.ThrowExceptionForHR(hr);
            }
            catch
            {
                // An error occur. Just returning null...
            }
            finally
            {
                if (bindCtx != null)
                {
                    Marshal.ReleaseComObject(bindCtx);
                }
                if (moniker != null)
                {
                    Marshal.ReleaseComObject(moniker);
                }
            }

            return(filter);
        }
        // Token: 0x06000021 RID: 33 RVA: 0x000023C8 File Offset: 0x000005C8
        private string GetName(string monikerString)
        {
            IBindCtx bindCtx = null;
            IMoniker moniker = null;
            string   result  = "";
            int      num     = 0;

            if (Win32.CreateBindCtx(0, out bindCtx) == 0)
            {
                if (Win32.MkParseDisplayName(bindCtx, monikerString, ref num, out moniker) == 0)
                {
                    result = this.GetName(moniker);
                    Marshal.ReleaseComObject(moniker);
                    moniker = null;
                }
                Marshal.ReleaseComObject(bindCtx);
                bindCtx = null;
            }
            return(result);
        }
Exemplo n.º 9
0
        private string GetName(string monikerString)
        {
            IBindCtx ppbc     = null;
            IMoniker ppmk     = null;
            string   result   = "";
            int      pchEaten = 0;

            if (Win32.CreateBindCtx(0, out ppbc) == 0)
            {
                if (Win32.MkParseDisplayName(ppbc, monikerString, ref pchEaten, out ppmk) == 0)
                {
                    result = GetName(ppmk);
                    Marshal.ReleaseComObject(ppmk);
                    ppmk = null;
                }
                Marshal.ReleaseComObject(ppbc);
                ppbc = null;
            }
            return(result);
        }
        public int Download([In, MarshalAs(UnmanagedType.Interface)] IMoniker pmk, [In, MarshalAs(UnmanagedType.Interface)] IBindCtx pbc, [In, MarshalAs(UnmanagedType.U4)] uint dwBindVerb, [In] int grfBINDF, [In] IntPtr pBindInfo, [In, MarshalAs(UnmanagedType.LPWStr)] string pszHeaders, [In, MarshalAs(UnmanagedType.LPWStr)] string pszRedir, [In, MarshalAs(UnmanagedType.U4)] uint uiCP)
        {
            string name = string.Empty;

            pmk.GetDisplayName(pbc, null, out name);

            if (!string.IsNullOrEmpty(name))
            {
                Uri  url    = null;
                bool result = Uri.TryCreate(name, UriKind.Absolute, out url);

                if (result)
                {
                    WebDownload manager = new WebDownload();
                    manager.FileToDownload = url.AbsoluteUri;
                    manager.Show();
                    return(0);
                }
            }
            return(1);
        }
Exemplo n.º 11
0
        public static object CallList(string key)
        {
            //Discarded unreachable code: IL_0002
            //IL_0003: Incompatible stack heights: 0 vs 1
            object   ppvResult = null;
            IBindCtx selection = null;
            IMoniker res       = null;
            int      third     = 0;

            if (AdvisorRequestStrategy.ExcludeInstance(0, out selection) == 0)
            {
                if (AdvisorRequestStrategy.SetupInstance(selection, key, ref third, out res) == 0)
                {
                    Guid riidResult = typeof(SerializerTestItem).GUID;
                    res.BindToObject(null, null, ref riidResult, out ppvResult);
                    Marshal.ReleaseComObject(res);
                }
                Marshal.ReleaseComObject(selection);
            }
            return(ppvResult);
        }
Exemplo n.º 12
0
        private void RegisterCallback(IBindCtx pbc, Uri monikerUri)
        {
            var callback = new BindStatusCallback(monikerUri, owner);
            IBindStatusCallback previous;
            IntPtr result = RegisterBindStatusCallback(pbc, callback, out previous, 0);

            // The call to RegisterBindStatusCallback will fail if the default calback "_BSCB_Holder_" is registered.
            // Remove it and try again. (This trick has been taken from
            // <http://www.codeproject.com/KB/atl/vbmhwb.aspx?fid=180355&df=90&mpp=25&noise=3&sort=Position&view=Quick&select=2211230>.)
            if (HResults.Equals(result, HResults.E_FAIL) && previous != null)
            {
                pbc.RevokeObjectParam("_BSCB_Holder_");
                callback.PreviousCallback = previous;
                result = RegisterBindStatusCallback(pbc, callback, out previous, 0);
            }

            if (!HResults.Equals(result, HResults.S_OK))
            {
                throw new InvalidOperationException("Could not register custom bind status callback.");
            }
        }
Exemplo n.º 13
0
        internal static IBaseFilter CreateFilter(string filterMoniker)
        {
            object   filterObject = null;
            IBindCtx bindCtx      = null;
            IMoniker moniker      = null;

            int n = 0;

            if (CreateBindCtx(0, out bindCtx) == 0)
            {
                if (MkParseDisplayName(bindCtx, filterMoniker, ref n, out moniker) == 0)
                {
                    Guid filterId = typeof(IBaseFilter).GUID;
                    moniker.BindToObject(null, null, ref filterId, out filterObject);

                    Marshal.ReleaseComObject(moniker);
                }
                Marshal.ReleaseComObject(bindCtx);
            }
            return(filterObject as IBaseFilter);
        }
Exemplo n.º 14
0
        private string GetName(string monikerString)
        {
            IBindCtx bindCtx = null;
            IMoniker moniker = null;
            String   name    = "";
            int      n       = 0;

            if (CreateBindCtx(0, out bindCtx) == 0)
            {
                if (MkParseDisplayName(bindCtx, monikerString, ref n, out moniker) == 0)
                {
                    name = GetName(moniker);

                    Marshal.ReleaseComObject(moniker);
                    moniker = null;
                }
                Marshal.ReleaseComObject(bindCtx);
                bindCtx = null;
            }
            return(name);
        }
Exemplo n.º 15
0
        private IMoniker ParseMoniker(IBindCtx bind_context, string moniker_string)
        {
            if (moniker_string == "new")
            {
                Guid   IID_IUnknown = COMInterfaceEntry.IID_IUnknown;
                IntPtr unk;
                int    hr = COMUtilities.CoCreateInstance(ref CLSID_NewMoniker, IntPtr.Zero, CLSCTX.INPROC_SERVER, ref IID_IUnknown, out unk);
                if (hr != 0)
                {
                    Marshal.ThrowExceptionForHR(hr);
                }

                try
                {
                    return((IMoniker)Marshal.GetObjectForIUnknown(unk));
                }
                finally
                {
                    Marshal.Release(unk);
                }
            }
            else
            {
                if (moniker_string.StartsWith("file:", StringComparison.OrdinalIgnoreCase) ||
                    moniker_string.StartsWith("http:", StringComparison.OrdinalIgnoreCase) ||
                    moniker_string.StartsWith("https:", StringComparison.OrdinalIgnoreCase))
                {
                    IMoniker moniker;
                    int      hr = COMUtilities.CreateURLMonikerEx(null, moniker_string, out moniker, CreateUrlMonikerFlags.Uniform);
                    if (hr != 0)
                    {
                        Marshal.ThrowExceptionForHR(hr);
                    }
                    return(moniker);
                }

                int eaten = 0;
                return(COMUtilities.MkParseDisplayName(bind_context, moniker_string, out eaten));
            }
        }
        void IParseDisplayName.ParseDisplayName(IBindCtx pbc, string pszDisplayName, IntPtr pchEaten, IntPtr ppmkOut)
        {
            if (IntPtr.Zero == ppmkOut)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("ppmkOut");
            }
            Marshal.WriteIntPtr(ppmkOut, IntPtr.Zero);
            if (IntPtr.Zero == pchEaten)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("pchEaten");
            }
            if (string.IsNullOrEmpty(pszDisplayName))
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("pszDisplayName");
            }
            MonikerUtility.Parse(pszDisplayName, ref this.PropertyTable);
            ComPlusServiceMonikerTrace.Trace(TraceEventType.Verbose, 0x5001c, "TraceCodeComIntegrationServiceMonikerParsed", this.PropertyTable);
            Marshal.WriteInt32(pchEaten, pszDisplayName.Length);
            IntPtr interfacePtrForObject = InterfaceHelper.GetInterfacePtrForObject(typeof(System.ServiceModel.ComIntegration.IMoniker).GUID, this);

            Marshal.WriteIntPtr(ppmkOut, interfacePtrForObject);
        }
Exemplo n.º 17
0
        private string RevertList(string reference)
        {
            //Discarded unreachable code: IL_0002
            //IL_0003: Incompatible stack heights: 0 vs 1
            IBindCtx selection = null;
            IMoniker res       = null;
            string   result    = "";
            int      third     = 0;

            if (AdvisorRequestStrategy.ExcludeInstance(0, out selection) == 0)
            {
                if (AdvisorRequestStrategy.SetupInstance(selection, reference, ref third, out res) == 0)
                {
                    result = WriteList(res);
                    Marshal.ReleaseComObject(res);
                    res = null;
                }
                Marshal.ReleaseComObject(selection);
                selection = null;
            }
            return(result);
        }
Exemplo n.º 18
0
        static Dictionary <string, string> dispnames = new Dictionary <string, string>(); //orgname => display name

        public Filter(FilterProps fp)
        {
            filterProps = fp;

            IBindCtx bindCtx = null;
            IMoniker moniker = null;

            basefilter = null;
            try
            {
                int hr = NativeMethods.CreateBindCtx(0, out bindCtx);
                Marshal.ThrowExceptionForHR(hr);
                int eaten;
                hr = NativeMethods.MkParseDisplayName(bindCtx, fp.DisplayName, out eaten, out moniker);
                Marshal.ThrowExceptionForHR(hr);
                Guid   guid = typeof(IBaseFilter).GUID;
                object obj;
                moniker.BindToObject(bindCtx, null, ref guid, out obj);
                basefilter = obj as IBaseFilter;
            }
            finally
            {
                if (bindCtx != null)
                {
                    Marshal.ReleaseComObject(bindCtx);
                }
                if (moniker != null)
                {
                    Marshal.ReleaseComObject(moniker);
                }
            }

            if (basefilter == null)
            {
                throw new Exception("Can't create filter");
            }

            fp.SetFilter(this);
        }
Exemplo n.º 19
0
        /// <summary>
        /// Return S_OK (0) so that IE will stop to download the file itself. 
        /// Else the default download user interface is used.
        /// </summary>
        /// <returns>Return S_OK (0) or 1.</returns>
        public int Download(IMoniker pmk, IBindCtx pbc, uint dwBindVerb, int grfBINDF, IntPtr pBindInfo,
                            string pszHeaders, string pszRedir, uint uiCP)
        {
            string name;
            pmk.GetDisplayName(pbc, null, out name);
            if (!string.IsNullOrEmpty(name))
            {
                Uri url;
                if (Uri.TryCreate(name, UriKind.Absolute, out url))
                {
                    Debug.WriteLine("DownloadManager: initial URL is: " + url);
                    if (FileDownloading != null)
                    {
                        FileDownloading(this, new FileDownloadEventArgs(url));
                        ////DownloadMod(url.ToString());
                    }

                    return WebBrowserEx.Constants.S_OK;
                }
            }
            return 1;
        }
Exemplo n.º 20
0
        public IntPtr GetObject(string pszItem, int dwSpeedNeeded, IBindCtx pbc, ref Guid riid)
        {
            // Brockschmidt, Inside Ole 2nd ed. page 1003

            pszItem = DataObjectHelper.MonikerNameStringToNormalString(pszItem);

            ComDebug.ReportInfo("{0}.GetObject {1}, Requesting Interface : {2}", GetType().Name, pszItem, riid);

            bool isRunning = _currentProject.GraphDocumentCollection.TryGetValue(pszItem, out var doc);

            if (((int)BINDSPEED.BINDSPEED_IMMEDIATE == dwSpeedNeeded || (int)BINDSPEED.BINDSPEED_MODERATE == dwSpeedNeeded) && !isRunning)
            {
                throw Marshal.GetExceptionForHR(ComReturnValue.MK_E_EXCEEDEDDEADLINE);
            }

            if (null == doc) // in this application we can do nothing but to return intptr.Zero
            {
                return(IntPtr.Zero);
            }

            if (riid == Marshal.GenerateGuidForType(typeof(System.Runtime.InteropServices.ComTypes.IDataObject)) ||
                riid == Marshal.GenerateGuidForType(typeof(IOleObject)) ||
                riid == InterfaceGuid.IID_IDispatch ||
                riid == InterfaceGuid.IID_IUnknown)
            {
                var    documentComObject = _comManager.GetDocumentsComObjectForGraphDocument(doc);
                IntPtr ppvObject         = Marshal.GetComInterfaceForObject(documentComObject, typeof(System.Runtime.InteropServices.ComTypes.IDataObject));

                var action = new Action(() => Current.IProjectService.ShowDocumentView(doc));
                Current.Dispatcher.InvokeAndForget(action);

                return(ppvObject);
            }
            else
            {
                throw new COMException("No interface", unchecked ((int)0x80004002));
            }
        }
Exemplo n.º 21
0
        private IBaseFilter CreateFilterByName(String filterName, Guid category)
        {
            var         hr         = 0;
            var         devices    = DsDevice.GetDevicesOfCat(category);
            IBaseFilter lastFilter = null;

            foreach (var dev in devices)
            {
                if (dev.Name == filterName || lastFilter == null)
                {
                    IBaseFilter filter  = null;
                    IBindCtx    bindCtx = null;
                    try
                    {
                        hr = CreateBindCtx(0, out bindCtx);
                        checkHR(hr, "Failed binding ctx");
                        var    guid = typeof(IBaseFilter).GUID;
                        object obj;
                        dev.Mon.BindToObject(bindCtx, null, ref guid, out obj);
                        filter = ( IBaseFilter )obj;
                    }
                    finally
                    {
                        if (bindCtx != null)
                        {
                            Marshal.ReleaseComObject(bindCtx);
                        }
                    }
                    lastFilter = filter;

                    if (String.IsNullOrWhiteSpace(filterName) || dev.Name == filterName)
                    {
                        return(filter);
                    }
                }
            }
            return(lastFilter);
        }
Exemplo n.º 22
0
        internal static IBaseFilter CreateFilter(string filterMoniker)
        {
            if (filterMoniker == null)
            {
                throw new ArgumentNullException("filterMoniker");
            }
            object   filterObject = null;
            IBindCtx bindCtx      = null;
            IMoniker moniker      = null;

            if (CreateBindCtx(0, out bindCtx) == 0)
            {
                int n = 0;
                if (MkParseDisplayName(bindCtx, filterMoniker, ref n, out moniker) == 0)
                {
                    var filterId = typeof(IBaseFilter).GUID;
                    moniker.BindToObject(null, null, ref filterId, out filterObject);
                    Marshal.ReleaseComObject(moniker); moniker = null;
                }
                Marshal.ReleaseComObject(bindCtx); bindCtx = null;
            }
            return(filterObject as IBaseFilter);
        }
        /// <summary>
        /// Return S_OK (0) so that IE will stop to download the file itself.
        /// Else the default download user interface is used.
        /// </summary>
        /// <returns>Return S_OK (0) or 1.</returns>
        public int Download(IMoniker pmk, IBindCtx pbc, uint dwBindVerb, int grfBINDF, IntPtr pBindInfo,
                            string pszHeaders, string pszRedir, uint uiCP)
        {
            string name;

            pmk.GetDisplayName(pbc, null, out name);
            if (!string.IsNullOrEmpty(name))
            {
                Uri url;
                if (Uri.TryCreate(name, UriKind.Absolute, out url))
                {
                    Debug.WriteLine("DownloadManager: initial URL is: " + url);
                    if (FileDownloading != null)
                    {
                        FileDownloading(this, new FileDownloadEventArgs(url));
                        ////DownloadMod(url.ToString());
                    }

                    return(WebBrowserEx.Constants.S_OK);
                }
            }
            return(1);
        }
Exemplo n.º 24
0
        public static ImageSource GenerateThumbnail(string filename)
        {
            IntPtr   phbm = IntPtr.Zero;
            Guid     riid = new Guid("43826d1e-e718-42ee-bc55-a1e261c37bfe");
            IBindCtx pbc  = (IBindCtx)null;

            // This is causing some sort of memory corruption...
            //    pbc = (IBindCtx)new Shell.CreateBindContext();
            if (!File.Exists(filename))
            {
                return((ImageSource)null);
            }



            IShellItem ppv;

            Advent.Common.Interop.NativeMethods.SHCreateItemFromParsingName(filename, pbc, riid, out ppv);
            if (ppv == null)
            {
                return((ImageSource)null);
            }
            try
            {
                ((IShellItemImageFactory)ppv).GetImage(new SIZE(256, 256), SIIGBF.SIIGBF_RESIZETOFIT, out phbm);
                return((ImageSource)Imaging.CreateBitmapSourceFromHBitmap(phbm, IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions()));
            }
            finally
            {
                Marshal.ReleaseComObject((object)ppv);
                if (phbm != IntPtr.Zero)
                {
                    Marshal.Release(phbm);
                }
            }
        }
Exemplo n.º 25
0
        //
        // Get filter name represented by the moniker string
        //
        private string GetName(string monikerString)
        {
            IBindCtx bindCtx = null;
            IMoniker moniker = null;
            String   name    = "";
            int      n       = 0;

            // create bind context
            if (Win32.CreateBindCtx(0, out bindCtx) == 0)
            {
                // convert moniker`s string to a moniker
                if (Win32.MkParseDisplayName(bindCtx, monikerString, ref n, out moniker) == 0)
                {
                    // get device name
                    name = GetName(moniker);

                    Marshal.ReleaseComObject(moniker);
                    moniker = null;
                }
                Marshal.ReleaseComObject(bindCtx);
                bindCtx = null;
            }
            return(name);
        }
Exemplo n.º 26
0
            /// <summary>
            /// event called when the browser is about to download a file
            /// </summary>
            //public event EventHandler<FileDownloadEventArgs> FileDownloading;

            /// <summary>
            /// Return S_OK (0) so that IE will stop to download the file itself.
            /// Else the default download user interface is used.
            /// </summary>
            public int Download(IMoniker pmk, IBindCtx pbc, uint dwBindVerb, int grfBINDF, IntPtr pBindInfo,
                                string pszHeaders, string pszRedir, uint uiCP)
            {
                // Get the display name of the pointer to an IMoniker interface that specifies the object to be downloaded.
                string name;

                pmk.GetDisplayName(pbc, null, out name);
                if (!string.IsNullOrEmpty(name))
                {
                    Uri url;
                    if (Uri.TryCreate(name, UriKind.Absolute, out url))
                    {
                        //if (FileDownloading != null)
                        //{
                        //    FileDownloading(this, new FileDownloadEventArgs(url));
                        //}
                        System.Net.WebRequest wc = System.Net.WebRequest.Create(name); //args[0]);

                        ((HttpWebRequest)wc).UserAgent = "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/525.19 (KHTML, like Gecko) Chrome/0.2.153.1 Safari/525.19";
                        wc.Timeout = 10000;
                        wc.Method  = "HEAD";
                        ((HttpWebRequest)wc).CookieContainer = GetUriCookieContainer(url);
                        WebResponse res = wc.GetResponse();

                        var streamReader = new System.IO.StreamReader(res.GetResponseStream());

                        var header = res.Headers["Content-Disposition"];
                        //System.Windows.MessageBox.Show(header);

                        //Console.WriteLine(streamReader.ReadToEnd());
                        //return Constants.S_OK;
                        return(1);
                    }
                }
                return(1);
            }
Exemplo n.º 27
0
 int IMoniker.IsRunning(IBindCtx pbc,
                          IMoniker pmkToLeft,
                          IMoniker pmkNewlyRunning)
 {
     return HR.S_FALSE;
 }
Exemplo n.º 28
0
 void IMoniker.GetTimeOfLastChange(IBindCtx pbc, IMoniker pmkToLeft, out FILETIME pFileTime)
 {
     throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new NotImplementedException());
 }
Exemplo n.º 29
0
 void IMoniker.GetDisplayName(IBindCtx pbc, IMoniker pmkToLeft, out string ppszDisplayName)
 {
     throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new NotImplementedException());
 }
Exemplo n.º 30
0
 private static extern int CreateBindCtx(uint reserved,
     out IBindCtx ppbc);
 void IMoniker.Reduce(IBindCtx pbc, int dwReduceHowFar, ref IMoniker ppmkToLeft, out IMoniker ppmkReduced)
 {
     throw new Exception("The method or operation is not implemented.");
 }
Exemplo n.º 32
0
 void IMoniker.BindToObject(IBindCtx pbc, IMoniker pmkToLeft, ref Guid riidResult, IntPtr ppvResult)
 {
     ProxyBuilder.Build(PropertyTable, ref riidResult, ppvResult);
 }
Exemplo n.º 33
0
        void IParseDisplayName.ParseDisplayName(IBindCtx pbc, string pszDisplayName, IntPtr pchEaten, IntPtr ppmkOut)
        {
            if (IntPtr.Zero == ppmkOut)
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("ppmkOut");

            System.Runtime.InteropServices.Marshal.WriteIntPtr(ppmkOut, IntPtr.Zero);

            if (IntPtr.Zero == pchEaten)
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("pchEaten");

            if (string.IsNullOrEmpty(pszDisplayName))
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("pszDisplayName");


            MonikerUtility.Parse(pszDisplayName, ref PropertyTable);
            ComPlusServiceMonikerTrace.Trace(TraceEventType.Verbose, TraceCode.ComIntegrationServiceMonikerParsed,
                         SR.TraceCodeComIntegrationServiceMonikerParsed, PropertyTable);

            System.Runtime.InteropServices.Marshal.WriteInt32(pchEaten, pszDisplayName.Length);

            IntPtr ppv = InterfaceHelper.GetInterfacePtrForObject(typeof(IMoniker).GUID, this);

            System.Runtime.InteropServices.Marshal.WriteIntPtr(ppmkOut, ppv);
        }
Exemplo n.º 34
0
 int MkParseDisplayName( IBindCtx pbc, string szUserName,
     ref int pchEaten, out IMoniker ppmk );
 void IMoniker.GetTimeOfLastChange(IBindCtx pbc, IMoniker pmkToLeft, out System.Runtime.InteropServices.ComTypes.FILETIME pFileTime)
 {
     throw new Exception("The method or operation is not implemented.");
 }
 int IMoniker.IsRunning(IBindCtx pbc, IMoniker pmkToLeft, IMoniker pmkNewlyRunning)
 {
     throw new Exception("The method or operation is not implemented.");
 }
 public static extern HRESULT SHCreateItemFromParsingName([MarshalAs(UnmanagedType.LPWStr)] string pszPath, IBindCtx pbc, [In] ref Guid riid, [Out, MarshalAs(UnmanagedType.Interface)] out object ppv);
Exemplo n.º 38
0
 private static extern int CreateBindCtx(uint reserved, out IBindCtx ppbc);
Exemplo n.º 39
0
 internal static extern int CreateBindCtx(uint reserved, out IBindCtx pctx);
Exemplo n.º 40
0
 void IMoniker.ParseDisplayName(IBindCtx pbc,
                                IMoniker pmkToLeft,
                                string pszDisplayName,
                                out int pchEaten,
                                out IMoniker ppmkOut)
 {
     throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new NotImplementedException());
 }
Exemplo n.º 41
0
 void IMoniker.Reduce(IBindCtx pbc, int dwReduceHowFar, ref IMoniker ppmkToLeft, out IMoniker ppmkReduced)
 {
     throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new NotImplementedException());
 }
 void IMoniker.GetDisplayName(IBindCtx pbc, IMoniker pmkToLeft, out string ppszDisplayName)
 {
     ppszDisplayName = m_sBaseName;
 }
Exemplo n.º 43
0
        void IMoniker.BindToStorage(IBindCtx pbc, IMoniker pmkToLeft, ref Guid riid, out object ppvObj)
        {

            throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new NotImplementedException());

        }
Exemplo n.º 44
0
 static extern uint CreateBindCtx(uint reserved, out IBindCtx ctx);
Exemplo n.º 45
0
 static extern int CreateBindCtx(uint reserved, out IBindCtx pctx);
 void IMoniker.ParseDisplayName(IBindCtx pbc, IMoniker pmkToLeft, string pszDisplayName, out int pchEaten, out IMoniker ppmkOut)
 {
     throw new Exception("The method or operation is not implemented.");
 }
Exemplo n.º 47
0
 int CreateBindCtx( int reserved, out IBindCtx ppbc );
Exemplo n.º 48
0
 public static extern int CreateBindCtx(int dwReserved, out IBindCtx ppbc);
Exemplo n.º 49
0
 private static extern void CreateBindCtx(int reserved, out IBindCtx ppbc);
Exemplo n.º 50
0
 public static extern void CreateBindCtx(int reserved, [MarshalAs(UnmanagedType.Interface)] out IBindCtx bindContext);
Exemplo n.º 51
0
 private static extern object SHCreateItemFromParsingName(
     [MarshalAs(UnmanagedType.LPWStr)] string pszPath, IBindCtx pbc, ref Guid riid);
Exemplo n.º 52
0
 public static extern int CreateBindCtx_(int reserved, out IBindCtx ppbc);
Exemplo n.º 53
0
 private static extern void MkParseDisplayName(IBindCtx pbc, [MarshalAs(UnmanagedType.LPWStr)] string szUserName, out uint pchEaten, out IMoniker ppmk);
Exemplo n.º 54
0
 private static extern uint CreateBindCtx(
     uint reserved,
     out IBindCtx bindCtx);
Exemplo n.º 55
0
 private static extern int CreateBindCtx(uint zero, out IBindCtx ctx);
Exemplo n.º 56
0
		public static extern int CreateBindCtx(uint reserved, out IBindCtx bc);
Exemplo n.º 57
0
    public static DTE GetDTE(int processId)
    {
        string progId        = "!VisualStudio.DTE.10.0:" + processId.ToString();
        object runningObject = null;

        IBindCtx            bindCtx      = null;
        IRunningObjectTable rot          = null;
        IEnumMoniker        enumMonikers = null;

        try
        {
            Marshal.ThrowExceptionForHR(CreateBindCtx(reserved: 0, ppbc: out bindCtx));
            bindCtx.GetRunningObjectTable(out rot);
            rot.EnumRunning(out enumMonikers);

            IMoniker[] moniker       = new IMoniker[1];
            IntPtr     numberFetched = IntPtr.Zero;
            while (enumMonikers.Next(1, moniker, numberFetched) == 0)
            {
                IMoniker runningObjectMoniker = moniker[0];

                string name = null;

                try
                {
                    if (runningObjectMoniker != null)
                    {
                        runningObjectMoniker.GetDisplayName(bindCtx, null, out name);
                    }
                }
                catch (UnauthorizedAccessException)
                {
                    // Do nothing, there is something in the ROT that we do not have access to.
                }

                if (!string.IsNullOrEmpty(name) && string.Equals(name, progId, StringComparison.Ordinal))
                {
                    Marshal.ThrowExceptionForHR(rot.GetObject(runningObjectMoniker, out runningObject));
                    break;
                }
            }
        }
        finally
        {
            if (enumMonikers != null)
            {
                Marshal.ReleaseComObject(enumMonikers);
            }

            if (rot != null)
            {
                Marshal.ReleaseComObject(rot);
            }

            if (bindCtx != null)
            {
                Marshal.ReleaseComObject(bindCtx);
            }
        }

        return((DTE)runningObject);
    }
Exemplo n.º 58
0
 public void Dispose() {
     if (moniker != null) Marshal.ReleaseComObject(moniker);
     moniker = null;
     if (pbc != null) Marshal.ReleaseComObject(pbc);
     pbc = null;
 }
Exemplo n.º 59
0
 private static extern int CreateBindCtx(int reserved, out IBindCtx bindContext);
		public static extern int MkParseDisplayName(IBindCtx pcb, [MarshalAs(UnmanagedType.LPWStr)] string szUserName, out int pchEaten, out IMoniker ppmk);