示例#1
0
文件: GACUtil.cs 项目: zha0/wspe
        /// <summary>
        /// Parse all the Assemblies from the Global Assembly Cache (GAC).
        /// </summary>
        /// <param name="wszFilter">Assembly to find.</param>
        /// <param name="wMajor">Major version of the Assembly to find</param>
        /// <param name="pAssemblyIdentity">Pointer to an ASSEMBLY_IDENTITY structure.</param>
        /// <returns>Whether the function successfully executed</returns>
        private uint ParseAllAssembliesInternal(string wszFilter, short wMajor, ref ASSEMBLY_IDENTITY pAssemblyIdentity)
        {
            // Parse all assemblies
            while (this.pIAssemblyEnum.GetNextAssembly(IntPtr.Zero, out IAssemblyName pIassemblyName, 0) == 0)
            {
                string wszAssemblyName = "";
                this.GetAssemblyName(ref pIassemblyName, ref wszAssemblyName);

                string wszAssemblyGacPath = "";
                this.GetAssemblyGACPath(ref wszAssemblyName, ref wszAssemblyGacPath);

                ASSEMBLY_VERSION AssemblyVersion = new ASSEMBLY_VERSION();
                this.GetAssemblyVersion(ref pIassemblyName, ref AssemblyVersion);

                // Search for an Assembly
                if ((!string.IsNullOrEmpty(wszFilter) && wszFilter.Equals(wszAssemblyName)) && (wMajor != 0) && wMajor == AssemblyVersion.wMajor)
                {
                    if (pAssemblyIdentity.Equals(null))
                    {
                        return(Macros.E_FAIL);
                    }

                    pAssemblyIdentity.szName    = wszFilter;
                    pAssemblyIdentity.szGacPath = wszAssemblyGacPath;
                    pAssemblyIdentity.szVersion = AssemblyVersion.wMajor + "." + AssemblyVersion.wMinor + "." + AssemblyVersion.wBuild + "." + AssemblyVersion.wRevision;
                    return(Macros.S_OK);
                }
            }

            if (!string.IsNullOrEmpty(wszFilter))
            {
                return(Macros.E_FAIL);
            }
            return(Macros.S_OK);
        }
示例#2
0
文件: GACUtil.cs 项目: zha0/wspe
        /// <summary>
        /// Get the version of an Assembly.
        /// </summary>
        /// <param name="pIAssemblyName">Pointer to an IAssemblyName interface.</param>
        /// <param name="pAssemblyVersion">Pointer to an ASSEMBLY_VERSION structure.</param>
        /// <returns>Whether the function successfully executed.</returns>
        public uint GetAssemblyVersion(ref IAssemblyName pIAssemblyName, ref ASSEMBLY_VERSION pAssemblyVersion)
        {
            if (pIAssemblyName == null || pAssemblyVersion.Equals(null))
            {
                return(Macros.E_FAIL);
            }

            pIAssemblyName.GetVersion(out uint dwHigh, out uint dwLow);
            pAssemblyVersion.wMajor    = (short)(dwHigh >> 0x10);
            pAssemblyVersion.wMinor    = (short)(dwHigh & 0xff);
            pAssemblyVersion.wBuild    = (short)(dwLow >> 0x10);
            pAssemblyVersion.wRevision = (short)(dwLow & 0xff);
            return(Macros.S_OK);
        }