// Token: 0x06004FF3 RID: 20467 RVA: 0x00119454 File Offset: 0x00117654
        internal static void GetEntryPoint(ActivationContext activationContext, out string fileName, out string parameters)
        {
            parameters = null;
            fileName   = null;
            ICMS applicationComponentManifest = activationContext.ApplicationComponentManifest;

            if (applicationComponentManifest == null || applicationComponentManifest.EntryPointSection == null)
            {
                throw new ArgumentException(Environment.GetResourceString("Argument_NoMain"));
            }
            IEnumUnknown enumUnknown = (IEnumUnknown)applicationComponentManifest.EntryPointSection._NewEnum;
            uint         num         = 0U;

            object[] array = new object[1];
            if (enumUnknown.Next(1U, array, ref num) == 0 && num == 1U)
            {
                IEntryPointEntry entryPointEntry = (IEntryPointEntry)array[0];
                EntryPointEntry  allData         = entryPointEntry.AllData;
                if (allData.CommandLine_File != null && allData.CommandLine_File.Length > 0)
                {
                    fileName = allData.CommandLine_File;
                }
                else
                {
                    object obj = null;
                    if (allData.Identity != null)
                    {
                        ((ISectionWithReferenceIdentityKey)applicationComponentManifest.AssemblyReferenceSection).Lookup(allData.Identity, out obj);
                        IAssemblyReferenceEntry assemblyReferenceEntry = (IAssemblyReferenceEntry)obj;
                        fileName = assemblyReferenceEntry.DependentAssembly.Codebase;
                    }
                }
                parameters = allData.CommandLine_Parameters;
            }
        }
        // Token: 0x06004FF4 RID: 20468 RVA: 0x00119534 File Offset: 0x00117734
        internal static IAssemblyReferenceEntry[] GetDependentAssemblies(ActivationContext activationContext)
        {
            IAssemblyReferenceEntry[] array   = null;
            ICMS applicationComponentManifest = activationContext.ApplicationComponentManifest;

            if (applicationComponentManifest == null)
            {
                return(null);
            }
            ISection assemblyReferenceSection = applicationComponentManifest.AssemblyReferenceSection;
            uint     num = (assemblyReferenceSection != null) ? assemblyReferenceSection.Count : 0U;

            if (num > 0U)
            {
                uint num2 = 0U;
                array = new IAssemblyReferenceEntry[num];
                IEnumUnknown enumUnknown = (IEnumUnknown)assemblyReferenceSection._NewEnum;
                int          num3        = enumUnknown.Next(num, array, ref num2);
                if (num2 != num || num3 < 0)
                {
                    return(null);
                }
            }
            return(array);
        }
Пример #3
0
        static Guid[] GetAllPixelFormats()
        {
            List <Guid> res = new List <Guid>();

            IWICImagingFactory factory = (IWICImagingFactory) new WICImagingFactory();
            IEnumUnknown       eu      = factory.CreateComponentEnumerator(WICComponentType.WICPixelFormat, WICComponentEnumerateOptions.WICComponentEnumerateRefresh);
            int hr = 0;

            object[] o = new object[1];
            while (hr == 0)
            {
                uint fetched = 0;

                hr = eu.Next(1, o, ref fetched);
                if (fetched == 1)
                {
                    IWICPixelFormatInfo info = (IWICPixelFormatInfo)o[0];
                    Guid guid;
                    info.GetFormatGUID(out guid);
                    res.Add(guid);

                    info.ReleaseComObject();
                }
                o.ReleaseComObject();
            }

            return(res.ToArray());
        }
Пример #4
0
        private static ICLRRuntimeInfo GetRuntime(IEnumUnknown runtimes, string version)
        {
            var  tempObjects = new object[3];
            uint fetchedCount;

            do
            {
                runtimes.Next((uint)tempObjects.Length, tempObjects, out fetchedCount);

                for (int i = 0; i < fetchedCount; i++)
                {
                    var runtimeInfo = (ICLRRuntimeInfo)tempObjects[i];

                    if (string.IsNullOrEmpty(version))
                    {
                        return(runtimeInfo);
                    }

                    var builder       = new StringBuilder(16);
                    var builderLength = (uint)builder.Capacity;
                    runtimeInfo.GetVersionString(builder, ref builderLength);

                    if (builder.ToString().StartsWith(version, StringComparison.Ordinal))
                    {
                        return(runtimeInfo);
                    }
                }
            } while (fetchedCount == tempObjects.Length);

            return(null);
        }
Пример #5
0
		public static IClrRuntimeInfo GetRuntime(IEnumUnknown runtimes, String version)
		{			
		    Object[] temparr = new Object[3];
		    UInt32 fetchedNum;
		    do
		    {			    	
		        runtimes.Next(Convert.ToUInt32(temparr.Length), temparr, out fetchedNum);
		
		        for (Int32 i = 0; i < fetchedNum; i++)
		        {
		            IClrRuntimeInfo t = (IClrRuntimeInfo)temparr[i];
		
		            // version not specified we return the first one
		            if (String.IsNullOrEmpty(version))
		            {
		                return t;
		            }
		
		            // initialize buffer for the runtime version string
		            StringBuilder sb = new StringBuilder(16);
		            UInt32 len = Convert.ToUInt32(sb.Capacity);
		            t.GetVersionString(sb, ref len);
		            "version: {0}".info(sb.str());
		            if (sb.ToString().StartsWith(version, StringComparison.Ordinal))
		            {
		                return t;
		            }
		        }
		    } while (fetchedNum == temparr.Length);
		
		    return null;
		}	
Пример #6
0
        public static IClrRuntimeInfo GetRuntime(IEnumUnknown runtimes, String version)
        {
            Object[] temparr = new Object[3];

            UInt32 fetchedNum;

            do
            {
                runtimes.Next(Convert.ToUInt32(temparr.Length), temparr, out fetchedNum);

                for (Int32 i = 0; i < fetchedNum; i++)
                {
                    IClrRuntimeInfo t = (IClrRuntimeInfo)temparr[i];

                    // version not specified we return the first one
                    if (String.IsNullOrEmpty(version))
                    {
                        return(t);
                    }

                    // initialize buffer for the runtime version string
                    StringBuilder sb  = new StringBuilder(16);
                    UInt32        len = Convert.ToUInt32(sb.Capacity);
                    t.GetVersionString(sb, ref len);
                    "version: {0}".info(sb.str());
                    if (sb.ToString().StartsWith(version, StringComparison.Ordinal))
                    {
                        return(t);
                    }
                }
            } while (fetchedNum == temparr.Length);

            return(null);
        }
Пример #7
0
        internal static IAssemblyReferenceEntry[] GetDependentAssemblies(ActivationContext activationContext)
        {
            IAssemblyReferenceEntry[] entries = null;
            ICMS appManifest = activationContext.ApplicationComponentManifest;

            if (appManifest == null)
            {
                return(null);
            }

            ISection dependencySection = appManifest.AssemblyReferenceSection;
            uint     count             = (dependencySection != null) ? dependencySection.Count : 0;

            if (count > 0)
            {
                uint fetched = 0;
                entries = new IAssemblyReferenceEntry[count];
                IEnumUnknown dependencyEnum = (IEnumUnknown)dependencySection._NewEnum;
                int          hr             = dependencyEnum.Next(count, entries, ref fetched);
                if (fetched != count || hr < 0)
                {
                    return(null); //
                }
            }
            return(entries);
        }
Пример #8
0
        // Retrieve information about runtimes installed on the machine (i.e. in %WINDIR%\Microsoft.NET\)
        public IEnumerable <CLRRuntimeInfo> EnumerateInstalledRuntimes()
        {
            List <CLRRuntimeInfo> runtimes     = new List <CLRRuntimeInfo>();
            IEnumUnknown          enumRuntimes = m_metaHost.EnumerateInstalledRuntimes();

            // Since we're only getting one at a time, we can pass NULL for count.
            // S_OK also means we got the single element we asked for.
            for (object oIUnknown; enumRuntimes.Next(1, out oIUnknown, IntPtr.Zero) == 0; /* empty */)
            {
                runtimes.Add(new CLRRuntimeInfo(oIUnknown));
            }

            return(runtimes);
        }
Пример #9
0
        public static IEnumerable <object> AsEnumerable(this IEnumUnknown enumUnknown)
        {
            var buffer = new object[1];

            for (;;)
            {
                int length;
                enumUnknown.Next(1, buffer, out length);
                if (length != 1)
                {
                    break;
                }
                yield return(buffer[0]);
            }
        }
Пример #10
0
        // Checks if device supports Content Directory service and opens a browser on it
        private void BrowseDevice(IUPnPDevice device)
        {
            // Get service enumerator
            IntPtr       pE    = device.Services._NewEnum;
            IEnumUnknown pEnum = (IEnumUnknown)Marshal.GetObjectForIUnknown(pE);

            Marshal.Release(pE);

            // Enumerate services. Look for one that has ContentDirectory in its description
            uint         cItems;
            IUPnPService svc         = null;
            IUPnPService svcContent  = null;
            bool         couldBrowse = false;

            while (pEnum.Next(1, out pE, out cItems) == 0 && cItems == 1)
            {
                svc = (IUPnPService)Marshal.GetObjectForIUnknown(pE);
                Marshal.Release(pE);

                object results;// = new object[3];
                object retVal;
                if (svc.ServiceTypeIdentifier.IndexOf("ContentDirectory", StringComparison.OrdinalIgnoreCase) >= 0)
                {
                    // Check if the service supports Browse verb
                    // This is not really neccessary, but just a precaution
                    svcContent = svc;
                    int hr = svc.InvokeAction("Browse", new object[] { "0", "BrowseDirectChildren", "*", 0, 0, "" }, out results, out retVal);
                    if (hr == 0)
                    {
                        couldBrowse = true;
                    }
                    hr = 0;
                }
            }

            if (!couldBrowse || svcContent == null)
            {
                MessageBox.Show("Found no browsable content");
            }
            else
            {
                // We have found the Content Directory
                Browser browser = new Browser(svcContent);
                browser.ShowDialog();
            }
        }
Пример #11
0
        void _buttonDropC_ExecuteEvent(object sender, ExecuteEventArgs e)
        {
            // enumerate over items
            IEnumUnknown itemsSource = (IEnumUnknown)_comboBox1.ItemsSource;

            itemsSource.Reset();
            object[] items = new object[1];
            uint     fetchedItem;

            while (itemsSource.Next(1, items, out fetchedItem) == HRESULT.S_OK)
            {
                IUISimplePropertySet uiItem = (IUISimplePropertySet)items[0];
                PropVariant          itemLabel;
                uiItem.GetValue(ref RibbonProperties.Label, out itemLabel);
                MessageBox.Show("Label = " + (string)itemLabel.Value);
            }
        }
Пример #12
0
        internal static void GetEntryPoint(ActivationContext activationContext, out string fileName, out string parameters)
        {
            parameters = (string)null;
            fileName   = (string)null;
            ICMS componentManifest = activationContext.ApplicationComponentManifest;

            if (componentManifest == null || componentManifest.EntryPointSection == null)
            {
                throw new ArgumentException(Environment.GetResourceString("Argument_NoMain"));
            }
            IEnumUnknown enumUnknown = (IEnumUnknown)componentManifest.EntryPointSection._NewEnum;
            uint         num1        = 0;

            object[] objArray = new object[1];
            int      num2     = 1;

            object[] rgelt = objArray;
            // ISSUE: explicit reference operation
            // ISSUE: variable of a reference type
            uint& celtFetched = @num1;

            if (enumUnknown.Next((uint)num2, rgelt, celtFetched) != 0 || (int)num1 != 1)
            {
                return;
            }
            EntryPointEntry allData = ((IEntryPointEntry)objArray[0]).AllData;

            if (allData.CommandLine_File != null && allData.CommandLine_File.Length > 0)
            {
                fileName = allData.CommandLine_File;
            }
            else
            {
                object ppUnknown = (object)null;
                if (allData.Identity != null)
                {
                    ((ISectionWithReferenceIdentityKey)componentManifest.AssemblyReferenceSection).Lookup(allData.Identity, out ppUnknown);
                    IAssemblyReferenceEntry assemblyReferenceEntry = (IAssemblyReferenceEntry)ppUnknown;
                    fileName = assemblyReferenceEntry.DependentAssembly.Codebase;
                }
            }
            parameters = allData.CommandLine_Parameters;
        }
Пример #13
0
        public static ICLRRuntimeInfo GetRuntime(IEnumUnknown runtimes, String version)
        {
            Object[]        temparr = new Object[3];
            uint            fetchedNum;
            String          highestVersion = null;
            ICLRRuntimeInfo result         = null;

            do
            {
                runtimes.Next(Convert.ToUInt32(temparr.Length), temparr, out fetchedNum);

                for (int i = 0; i < fetchedNum; i++)
                {
                    ICLRRuntimeInfo t = (ICLRRuntimeInfo)temparr[i];

                    // initialize buffer for the runtime version string
                    StringBuilder sb  = new StringBuilder(16);
                    UInt32        len = Convert.ToUInt32(sb.Capacity);
                    t.GetVersionString(sb, ref len);

                    // version not specified we return the first one
                    if (!String.IsNullOrEmpty(version))
                    {
                        if (sb.ToString().StartsWith(version, StringComparison.Ordinal))
                        {
                            return(t);
                        }
                    }
                    else
                    {
                        if (highestVersion == null || String.CompareOrdinal(version, highestVersion) > 0)
                        {
                            highestVersion = version;
                            result         = t;
                        }
                    }
                }
            } while (fetchedNum == temparr.Length);

            return(result);
        }
Пример #14
0
        private static IEnumerable <IWICComponentInfo> GetComponentInfos(WICComponentType type)
        {
            IWICImagingFactory factory = (IWICImagingFactory) new WICImagingFactoryCoClass();
            IEnumUnknown       eu      = null;

            object[] o = new object[1];

            try
            {
                eu = factory.CreateComponentEnumerator(type, WICComponentEnumerateOptions.WICComponentEnumerateDefault);

                int hr = 0;
                while (hr == 0)
                {
                    uint fetched = 0;
                    hr = eu.Next(1, o, ref fetched);
                    Marshal.ThrowExceptionForHR(hr);
                    if (fetched == 1)
                    {
                        IWICComponentInfo ci = (IWICComponentInfo)o[0];
                        try
                        {
                            yield return(ci);
                        }
                        finally
                        {
                            Marshal.ReleaseComObject(ci);
                        }
                    }
                }
            }
            finally
            {
                if (eu != null)
                {
                    Marshal.ReleaseComObject(eu);
                }
                Marshal.ReleaseComObject(factory);
            }
        }
Пример #15
0
        internal static void GetEntryPoint(ActivationContext activationContext, out string fileName, out string parameters)
        {
            parameters = null;
            fileName   = null;

            ICMS appManifest = activationContext.ApplicationComponentManifest;

            if (appManifest == null || appManifest.EntryPointSection == null)
            {
                throw new ArgumentException(Environment.GetResourceString("Argument_NoMain"));
            }

            IEnumUnknown refEnum = (IEnumUnknown)appManifest.EntryPointSection._NewEnum;
            uint         count   = 0;

            Object[] entries = new Object[1];
            // Look for the first entry point. ClickOnce semantic validation ensures exactly one entry point is present.
            if (refEnum.Next(1, entries, ref count) == 0 && count == 1)
            {
                IEntryPointEntry iref      = (IEntryPointEntry)entries[0];
                EntryPointEntry  reference = iref.AllData;
                if (reference.CommandLine_File != null && reference.CommandLine_File.Length > 0)
                {
                    fileName = reference.CommandLine_File;
                }
                else
                {
                    // Locate the dependent assembly that is being refered to. Well-formed manifests should have an identity.
                    IAssemblyReferenceEntry refEntry = null;
                    object assemblyObj = null;
                    if (reference.Identity != null)
                    {
                        ((ISectionWithReferenceIdentityKey)appManifest.AssemblyReferenceSection).Lookup(reference.Identity, out assemblyObj);
                        refEntry = (IAssemblyReferenceEntry)assemblyObj;
                        fileName = refEntry.DependentAssembly.Codebase;
                    }
                }
                parameters = reference.CommandLine_Parameters;
            }
        }
Пример #16
0
        /// <summary>
        /// Retrieves an array of the sub-conditions.
        /// </summary>
        public IEnumerable <SearchCondition> GetSubConditions()
        {
            // Our list that we'll return
            List <SearchCondition> subConditionsList = new List <SearchCondition>();

            // Get the sub-conditions from the native API
            object subConditionObj;
            Guid   guid = new Guid(ShellIIDGuid.IEnumUnknown);

            HResult hr = NativeSearchCondition.GetSubConditions(ref guid, out subConditionObj);

            if (!CoreErrorHelper.Succeeded(hr))
            {
                throw new ShellException(hr);
            }

            // Convert each ICondition to SearchCondition
            if (subConditionObj != null)
            {
                IEnumUnknown enumUnknown = subConditionObj as IEnumUnknown;

                IntPtr buffer  = IntPtr.Zero;
                uint   fetched = 0;

                while (hr == HResult.Ok)
                {
                    hr = enumUnknown.Next(1, ref buffer, ref fetched);

                    if (hr == HResult.Ok && fetched == 1)
                    {
                        subConditionsList.Add(new SearchCondition((ICondition)Marshal.GetObjectForIUnknown(buffer)));
                    }
                }
            }

            return(subConditionsList);
        }
Пример #17
0
        public static IEnumerable <IWICComponentInfo> GetComponentInfos(WICComponentType type)
        {
            IWICImagingFactory factory = (IWICImagingFactory) new WICImagingFactory();
            IEnumUnknown       eu      = null;

            object[] o = new object[1];

            try
            {
                eu = factory.CreateComponentEnumerator(type, WICComponentEnumerateOptions.WICComponentEnumerateRefresh | WICComponentEnumerateOptions.WICComponentEnumerateDisabled);

                int hr = 0;
                while (hr == 0)
                {
                    uint fetched = 0;
                    hr = eu.Next(1, o, ref fetched);
                    Marshal.ThrowExceptionForHR(hr);
                    if (fetched == 1)
                    {
                        IWICComponentInfo ci = (IWICComponentInfo)o[0];
                        try
                        {
                            yield return(ci);
                        }
                        finally
                        {
                            ci.ReleaseComObject();
                        }
                    }
                }
            }
            finally
            {
                factory.ReleaseComObject();
                eu.ReleaseComObject();
            }
        }
Пример #18
0
        internal static void GetEntryPoint(ActivationContext activationContext, out string fileName, out string parameters)
        {
            parameters = null;
            fileName   = null;
            ICMS applicationComponentManifest = activationContext.ApplicationComponentManifest;

            if ((applicationComponentManifest == null) || (applicationComponentManifest.EntryPointSection == null))
            {
                throw new ArgumentException(Environment.GetResourceString("Argument_NoMain"));
            }
            IEnumUnknown unknown     = (IEnumUnknown)applicationComponentManifest.EntryPointSection._NewEnum;
            uint         celtFetched = 0;

            object[] rgelt = new object[1];
            if ((unknown.Next(1, rgelt, ref celtFetched) == 0) && (celtFetched == 1))
            {
                IEntryPointEntry entry   = (IEntryPointEntry)rgelt[0];
                EntryPointEntry  allData = entry.AllData;
                if ((allData.CommandLine_File != null) && (allData.CommandLine_File.Length > 0))
                {
                    fileName = allData.CommandLine_File;
                }
                else
                {
                    IAssemblyReferenceEntry entry3 = null;
                    object ppUnknown = null;
                    if (allData.Identity != null)
                    {
                        ((ISectionWithReferenceIdentityKey)applicationComponentManifest.AssemblyReferenceSection).Lookup(allData.Identity, out ppUnknown);
                        entry3   = (IAssemblyReferenceEntry)ppUnknown;
                        fileName = entry3.DependentAssembly.Codebase;
                    }
                }
                parameters = allData.CommandLine_Parameters;
            }
        }
        private static ICLRRuntimeInfo GetRuntime(IEnumUnknown runtimes, string version)
        {
            var tempObjects = new object[3];
            uint fetchedCount;

            do
            {
                runtimes.Next((uint)tempObjects.Length, tempObjects, out fetchedCount);

                for (int i = 0; i < fetchedCount; i++)
                {
                    var runtimeInfo = (ICLRRuntimeInfo)tempObjects[i];

                    if (string.IsNullOrEmpty(version))
                    {
                        return runtimeInfo;
                    }

                    var builder = new StringBuilder(16);
                    var builderLength = (uint)builder.Capacity;
                    runtimeInfo.GetVersionString(builder, ref builderLength);

                    if (builder.ToString().StartsWith(version, StringComparison.Ordinal))
                    {
                        return runtimeInfo;
                    }
                }
            } while (fetchedCount == tempObjects.Length);

            return null;
        }