コード例 #1
0
        internal static SystemUtils.AssemblyInfo QueryAssemblyInfo(System.Deployment.Application.NativeMethods.IAssemblyCache AssemblyCache, SystemUtils.QueryAssemblyInfoFlags flags, string assemblyName)
        {
            string assemblyName1 = assemblyName;

            SystemUtils.AssemblyInfo assemblyInfo1 = new SystemUtils.AssemblyInfo();
            System.Deployment.Application.NativeMethods.AssemblyInfoInternal assemblyInfo2 = new System.Deployment.Application.NativeMethods.AssemblyInfoInternal();
            if ((flags & SystemUtils.QueryAssemblyInfoFlags.GetCurrentPath) != (SystemUtils.QueryAssemblyInfoFlags) 0)
            {
                assemblyInfo2.cchBuf = 1024;
                assemblyInfo2.currentAssemblyPathBuf = Marshal.AllocHGlobal(assemblyInfo2.cchBuf * 2);
            }
            else
            {
                assemblyInfo2.cchBuf = 0;
                assemblyInfo2.currentAssemblyPathBuf = (IntPtr)0;
            }
            try
            {
                AssemblyCache.QueryAssemblyInfo((int)flags, assemblyName1, ref assemblyInfo2);
            }
            catch (Exception ex)
            {
                if (ExceptionUtility.IsHardException(ex))
                {
                    throw;
                }
                else
                {
                    Logger.AddInternalState("Exception thrown : " + ex.GetType().ToString() + ":" + ex.Message);
                    assemblyInfo1 = (SystemUtils.AssemblyInfo)null;
                }
            }
            if (assemblyInfo1 != null)
            {
                assemblyInfo1.AssemblyInfoSizeInByte = assemblyInfo2.cbAssemblyInfo;
                assemblyInfo1.AssemblyFlags          = (SystemUtils.AssemblyInfoFlags)assemblyInfo2.assemblyFlags;
                assemblyInfo1.AssemblySizeInKB       = assemblyInfo2.assemblySizeInKB;
                if ((flags & SystemUtils.QueryAssemblyInfoFlags.GetCurrentPath) != (SystemUtils.QueryAssemblyInfoFlags) 0)
                {
                    assemblyInfo1.CurrentAssemblyPath = Marshal.PtrToStringUni(assemblyInfo2.currentAssemblyPathBuf);
                    Marshal.FreeHGlobal(assemblyInfo2.currentAssemblyPathBuf);
                }
            }
            return(assemblyInfo1);
        }
コード例 #2
0
        internal static AssemblyInfo QueryAssemblyInfo(System.Deployment.Application.NativeMethods.IAssemblyCache AssemblyCache, QueryAssemblyInfoFlags flags, string assemblyName)
        {
            string       str  = assemblyName;
            AssemblyInfo info = new AssemblyInfo();

            System.Deployment.Application.NativeMethods.AssemblyInfoInternal assemblyInfo = new System.Deployment.Application.NativeMethods.AssemblyInfoInternal();
            if ((flags & QueryAssemblyInfoFlags.GetCurrentPath) != 0)
            {
                assemblyInfo.cchBuf = 0x400;
                assemblyInfo.currentAssemblyPathBuf = Marshal.AllocHGlobal((int)(assemblyInfo.cchBuf * 2));
            }
            else
            {
                assemblyInfo.cchBuf = 0;
                assemblyInfo.currentAssemblyPathBuf = IntPtr.Zero;
            }
            try
            {
                AssemblyCache.QueryAssemblyInfo((int)flags, str, ref assemblyInfo);
            }
            catch (Exception exception)
            {
                if (ExceptionUtility.IsHardException(exception))
                {
                    throw;
                }
                Logger.AddInternalState("Exception thrown : " + exception.GetType().ToString() + ":" + exception.Message);
                info = null;
            }
            if (info != null)
            {
                info.AssemblyInfoSizeInByte = assemblyInfo.cbAssemblyInfo;
                info.AssemblyFlags          = (AssemblyInfoFlags)assemblyInfo.assemblyFlags;
                info.AssemblySizeInKB       = assemblyInfo.assemblySizeInKB;
                if ((flags & QueryAssemblyInfoFlags.GetCurrentPath) != 0)
                {
                    info.CurrentAssemblyPath = Marshal.PtrToStringUni(assemblyInfo.currentAssemblyPathBuf);
                    Marshal.FreeHGlobal(assemblyInfo.currentAssemblyPathBuf);
                }
            }
            return(info);
        }
コード例 #3
0
 internal static AssemblyInfo QueryAssemblyInfo(System.Deployment.Application.NativeMethods.IAssemblyCache AssemblyCache, QueryAssemblyInfoFlags flags, string assemblyName)
 {
     string str = assemblyName;
     AssemblyInfo info = new AssemblyInfo();
     System.Deployment.Application.NativeMethods.AssemblyInfoInternal assemblyInfo = new System.Deployment.Application.NativeMethods.AssemblyInfoInternal();
     if ((flags & QueryAssemblyInfoFlags.GetCurrentPath) != 0)
     {
         assemblyInfo.cchBuf = 0x400;
         assemblyInfo.currentAssemblyPathBuf = Marshal.AllocHGlobal((int) (assemblyInfo.cchBuf * 2));
     }
     else
     {
         assemblyInfo.cchBuf = 0;
         assemblyInfo.currentAssemblyPathBuf = IntPtr.Zero;
     }
     try
     {
         AssemblyCache.QueryAssemblyInfo((int) flags, str, ref assemblyInfo);
     }
     catch (Exception exception)
     {
         if (ExceptionUtility.IsHardException(exception))
         {
             throw;
         }
         Logger.AddInternalState("Exception thrown : " + exception.GetType().ToString() + ":" + exception.Message);
         info = null;
     }
     if (info != null)
     {
         info.AssemblyInfoSizeInByte = assemblyInfo.cbAssemblyInfo;
         info.AssemblyFlags = (AssemblyInfoFlags) assemblyInfo.assemblyFlags;
         info.AssemblySizeInKB = assemblyInfo.assemblySizeInKB;
         if ((flags & QueryAssemblyInfoFlags.GetCurrentPath) != 0)
         {
             info.CurrentAssemblyPath = Marshal.PtrToStringUni(assemblyInfo.currentAssemblyPathBuf);
             Marshal.FreeHGlobal(assemblyInfo.currentAssemblyPathBuf);
         }
     }
     return info;
 }